mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[Commands] Refactor command and group decorators (#1818)
* [V3 Commands] Refactor command and group decorators * Add some tests * Fix docs reference * Tweak Group's MRO
This commit is contained in:
@@ -8,8 +8,6 @@ from pathlib import Path
|
||||
|
||||
import discord
|
||||
import sys
|
||||
from discord.ext.commands.bot import BotBase
|
||||
from discord.ext.commands import GroupMixin
|
||||
from discord.ext.commands import when_mentioned_or
|
||||
|
||||
# This supresses the PyNaCl warning that isn't relevant here
|
||||
@@ -29,7 +27,7 @@ def _is_submodule(parent, child):
|
||||
return parent == child or child.startswith(parent + ".")
|
||||
|
||||
|
||||
class RedBase(BotBase, RPCMixin):
|
||||
class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin):
|
||||
"""Mixin for the main bot class.
|
||||
|
||||
This exists because `Red` inherits from `discord.AutoShardedClient`, which
|
||||
@@ -255,7 +253,7 @@ class RedBase(BotBase, RPCMixin):
|
||||
# first remove all the commands from the module
|
||||
for cmd in self.all_commands.copy().values():
|
||||
if cmd.module and _is_submodule(lib_name, cmd.module):
|
||||
if isinstance(cmd, GroupMixin):
|
||||
if isinstance(cmd, discord.ext.commands.GroupMixin):
|
||||
cmd.recursively_remove_all_commands()
|
||||
|
||||
self.remove_command(cmd.name)
|
||||
|
||||
Reference in New Issue
Block a user