OneTrueBen / pa-discordbot

0 stars 1 forks source link

Add aliases #20

Closed benjjs closed 4 years ago

benjjs commented 4 years ago

Add the ability to create and remove custom aliases for commands.

While discord.py commands do have a notion of alias, these built-in aliases cannot be dynamically modified and are instead constrained to those aliases specified in the command's definition.

Our implementation works by catching command errors and checking any unrecognized commands against a db table of aliases and then subsequently invoking the corresponding command if one is found. An alias can be created with the command *alias \ \* or deleted with the command removealias \**. Only mods can add or remove aliases.

A given alias may only be used for one command to prevent ambiguity, and the names of commands cannot be used as aliases for other commands.

As an added bonus, I've thrown in some better handling of command errors which are NOT caused by the use of an alias. If someone tries to use a command that doesn't exist, the bot will say so. If, however, the leading asterisk was simply being used to create italic text, the error will be silently ignored. Other possible command errors are unaffected.