aboutsummaryrefslogtreecommitdiffstats
path: root/bot/group.py
diff options
context:
space:
mode:
authorGravatar ToxicKidz <[email protected]>2021-05-03 13:00:23 -0400
committerGravatar ToxicKidz <[email protected]>2021-05-03 13:00:23 -0400
commitfa45ba761a4176a32e6ed8c55bd432876dd69aa6 (patch)
treebcdd5b195bbc703cf917d65af6e184ea2a2c21b2 /bot/group.py
parentfix: Don't pass bot to __init__ (diff)
parentMerge pull request #717 from ToxicKidz/pr-template-spelling-fix (diff)
fix: Resolve Merge Conflicts
Diffstat (limited to 'bot/group.py')
-rw-r--r--bot/group.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/group.py b/bot/group.py
new file mode 100644
index 00000000..a7bc59b7
--- /dev/null
+++ b/bot/group.py
@@ -0,0 +1,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.")