aboutsummaryrefslogtreecommitdiffstats
path: root/bot/monkey_patches.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bot/monkey_patches.py (renamed from bot/typing.py)18
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/typing.py b/bot/monkey_patches.py
index 4b1df3f2f..9c0a22bfb 100644
--- a/bot/typing.py
+++ b/bot/monkey_patches.py
@@ -2,10 +2,28 @@ import logging
from datetime import datetime, timedelta
from discord import Forbidden, http
+from discord.ext import commands
log = logging.getLogger(__name__)
+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.")
+
+
def patch_typing() -> None:
"""
Sometimes discord turns off typing events by throwing 403's.