[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:
Toby Harradine
2018-08-26 23:25:25 +10:00
committed by GitHub
parent f595afab18
commit 48a7a21aca
3 changed files with 51 additions and 14 deletions

View File

@@ -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)