aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-08-22 19:20:54 -0700
committerGravatar MarkKoz <[email protected]>2020-08-22 20:07:03 -0700
commit36ec4b31730ac7243fc76fe5140a0ed2e922940f (patch)
tree838837024207ef39b8a1298c6103a686c3efe72a
parentBot: add root alias support (diff)
Patch d.py decorators to support root aliases
To avoid explicitly specifying `cls` everywhere, patch the decorators to set the default value of `cls` to the `Command` subclass which supports root aliases.
-rw-r--r--bot/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index d63086fe2..3ee70c4e9 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -2,10 +2,14 @@ import asyncio
import logging
import os
import sys
+from functools import partial, partialmethod
from logging import Logger, handlers
from pathlib import Path
import coloredlogs
+from discord.ext import commands
+
+from bot.command import Command
TRACE_LEVEL = logging.TRACE = 5
logging.addLevelName(TRACE_LEVEL, "TRACE")
@@ -66,3 +70,9 @@ logging.getLogger(__name__)
# On Windows, the selector event loop is required for aiodns.
if os.name == "nt":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
+
+
+# Monkey-patch discord.py decorators to use the Command subclass which supports root aliases.
+# Must be patched before any cogs are added.
+commands.command = partial(commands.command, cls=Command)
+commands.GroupMixin.command = partialmethod(commands.GroupMixin.command, cls=Command)