Repository: Cog-Creators/Red-DiscordBot

Issue:
[CustomCom] Error on not capitalizing member
### What Red version are you using?

3.4.9

### Cog name

Customcom

### Command name

customcom create simple

### What did you expect to happen?

One of my bot users used the command, which I replicated due to their content not being appropriate. 
Usage: `[p]cc create simple test {0.mention:member} testing 1 2 3`

I would expect it to give back a message saying something along the lines that `{0.mention:member}` is not valid as you need to capitalize `M` in `member`, instead of just completely erroring out. This doesn't give any details to the user using it on what they'd need to fix in their custom command.

The correct way to use this command is:
`[p]cc create simple test {0.mention:Member} testing 1 2 3`

<img width="369" alt="LP9W8pGfqA" src="https://user-images.githubusercontent.com/42697462/117021027-3482a500-acb4-11eb-92da-d1f8182f4d73.png">


### What actually happened?

It errored out, saying to check console or logs rather than giving a message to explain.
<img width="490" alt="Z9YrREMfr1" src="https://user-images.githubusercontent.com/42697462/117020985-2b91d380-acb4-11eb-8037-9f06564b98c7.png">


### How can we reproduce this error?

1. Create a customcommand using `{0.mention:member}` as the output response.
2. Watch the response it gives, whether it'll fail or succeed.
3. Try again but capitalizing M in `member` to see confirm success. `{0.mention:Member}`



### Anything else?

Here is the traceback for the `member` not being capitalize at first.

```py
Traceback (most recent call last):
  File "/home/sharky/.local/lib/python3.8/site-packages/redbot/cogs/customcom/customcom.py", line 708, in prepare_args
    getattr(commands, anno.__name__ + "Converter")
AttributeError: module 'redbot.core.commands' has no attribute 'discord.memberConverter'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sharky/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/sharky/.local/lib/python3.8/site-packages/redbot/cogs/customcom/customcom.py", line 394, in cc_create_simple
    await self.commandobj.create(ctx=ctx, command=command, response=text)
  File "/home/sharky/.local/lib/python3.8/site-packages/redbot/cogs/customcom/customcom.py", line 135, in create
    ctx.cog.prepare_args(response if isinstance(response, str) else response[0])
  File "/home/sharky/.local/lib/python3.8/site-packages/redbot/cogs/customcom/customcom.py", line 710, in prepare_args
    anno = allowed_builtins.get(anno.lower(), Parameter.empty)
AttributeError: module 'discord.member' has no attribute 'lower'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/sharky/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/sharky/.local/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
    await super().invoke(ctx)
  File "/home/sharky/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1348, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/sharky/.local/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
    await super().invoke(ctx)
  File "/home/sharky/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1348, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/sharky/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/sharky/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.member' has no attribute 'lower'
```


Discussion:

Resolving patch:
diff --git a/redbot/cogs/customcom/customcom.py b/redbot/cogs/customcom/customcom.py
--- a/redbot/cogs/customcom/customcom.py
+++ b/redbot/cogs/customcom/customcom.py
@@ -694,20 +694,20 @@ def prepare_args(raw_response) -> Mapping[str, Parameter]:
         fin = [Parameter("_" + str(i), Parameter.POSITIONAL_OR_KEYWORD) for i in range(high + 1)]
         for arg in args:
             index = int(arg[0]) - low
-            anno = arg[1][1:]  # strip initial colon
-            if anno.lower().endswith("converter"):
-                anno = anno[:-9]
-            if not anno or anno.startswith("_"):  # public types only
+            anno_raw = arg[1][1:]  # strip initial colon
+            if anno_raw.lower().endswith("converter"):
+                anno_raw = anno_raw[:-9]
+            if not anno_raw or anno_raw.startswith("_"):  # public types only
                 name = "{}_{}".format("text", index if index < high else "final")
                 fin[index] = fin[index].replace(name=name)
                 continue
             # allow type hinting only for discord.py and builtin types
             try:
-                anno = getattr(discord, anno)
+                anno = getattr(discord, anno_raw)
                 # force an AttributeError if there's no discord.py converter
                 getattr(commands, anno.__name__ + "Converter")
             except AttributeError:
-                anno = allowed_builtins.get(anno.lower(), Parameter.empty)
+                anno = allowed_builtins.get(anno_raw.lower(), Parameter.empty)
             if (
                 anno is not Parameter.empty
                 and fin[index].annotation is not Parameter.empty


Test patch: