Adding an alias that is the same name as the function it decorates raises an exception, pointing out that the command name is already taken. This can be an issue when changing names of commands, for example to fix a naming convention violation. If I have aliases "pingme", "ping_me", and "PingMe", to try to cover as much ground as I can, an exception will be raised if I rename the command from "pingMe" to "ping_me".
This isn't a huge issue, but it happened to me. I just want to know whether other people feel like it should be changed too, or if it's not worth it.
If an alias of a command matches the command name, silently skip that alias.
Raises an exception if an alias matches the command name
Allow this:
@commands.command(aliases=["pingme", "ping_me", "PingMe"])
async def ping_me(self, ctx):
await ctx.send("Pong")
I don't see a point in this. The name of the function is already used as a way to call the command, so there is no reason to put it in the aliases as well.
@CapnS It just feels kind of pointless to raise an exception if it's clear what the user actually wanted. Some people might also like seeing all the ways to call the command in one list.
There isn't any critical point to this, but there is definitely a point.
well, aliases usually suggests alternative names, and it would be weird to put the main name in the alternative name list, also the aliases are grouped to the function so you can see both the list and the main name (assuming you don't set a name in the decorator) anyway
I know this is a bit late but i got curious and wanted to know why this happens. And in the add_command() function i found this:
for alias in command.aliases:
if alias in self.all_commands:
raise discord.ClientException('The alias {} is already an existing command or alias.'.format(alias))
self.all_commands[alias] = command
I believe what happens is that when using the in operator it eventually finds itself and then raises the exception. That line could simply be edited to something like
if alias in self.all_commands and alias != command.name:
Or just use pop() to remove any alias that has the same name as the command name. But it seems useless to do for just this one use case of i guess laziness?
Most helpful comment
well, aliases usually suggests alternative names, and it would be weird to put the main name in the alternative name list, also the aliases are grouped to the function so you can see both the list and the main name (assuming you don't set a name in the decorator) anyway