blob: a7bc59b70fc588d4eac71ebb611689f253128cf2 (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 | from discord.ext import commands
class Group(commands.Group):
    """
    A `discord.ext.commands.Group` 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 groups 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 group must be a list or a tuple of strings.")
 |