diff options
| author | 2021-06-03 15:58:05 +0800 | |
|---|---|---|
| committer | 2021-06-03 15:58:05 +0800 | |
| commit | b60fd23bae52fb59eed0bf29aef2516234d1c858 (patch) | |
| tree | 0ed0f44d590e8e4891b2f1ab142b10b48fae2763 /bot/command.py | |
| parent | Make `setup` docstring same as other cogs (diff) | |
| parent | Added "centisecond" in trivia_quiz.json (#751) (diff) | |
Merge branch 'main' into feature/pride-leaders
Diffstat (limited to 'bot/command.py')
| -rw-r--r-- | bot/command.py | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/bot/command.py b/bot/command.py new file mode 100644 index 00000000..0fb900f7 --- /dev/null +++ b/bot/command.py @@ -0,0 +1,18 @@ +from discord.ext import commands + + +class Command(commands.Command): +    """ +    A `discord.ext.commands.Command` subclass which supports root aliases. + +    A `root_aliases` keyword argument is added, which is a sequence of alias names that will act as +    top-level commands rather than being aliases of the command's group. It's stored as an attribute +    also named `root_aliases`. +    """ + +    def __init__(self, *args, **kwargs): +        super().__init__(*args, **kwargs) +        self.root_aliases = kwargs.get("root_aliases", []) + +        if not isinstance(self.root_aliases, (list, tuple)): +            raise TypeError("Root aliases of a command must be a list or a tuple of strings.") | 
