[V3] Enforce use of redbot.core.commands (#1971)

* enforce commands as ours

* clearer user feedback

* No more 'one more tweak' commits without verifying anyway

* more detailed error with docs link + docs update

Resolves #1972.
This commit is contained in:
Michael H
2018-08-12 21:10:13 -04:00
committed by Toby Harradine
parent a91cda4995
commit 6082eb21e3
2 changed files with 19 additions and 2 deletions

View File

@@ -291,6 +291,22 @@ class RedBase(BotBase, RPCMixin):
if pkg_name.startswith("redbot.cogs."):
del sys.modules["redbot.cogs"].__dict__[name]
def add_cog(self, cog):
for attr in dir(cog):
_attr = getattr(cog, attr)
if isinstance(_attr, discord.ext.commands.Command) and not isinstance(
_attr, commands.Command
):
raise RuntimeError(
f"The {cog.__class__.__name__} cog in the {cog.__module__} package,"
" is not using Red's command module, and cannot be added. "
"If this is your cog, please use from `redbot.core import commands`"
"in place of `from discord.ext import commands`. For more details on "
"this requirement, see this page: "
"http://red-discordbot.readthedocs.io/en/v3-develop/framework_commands.html"
)
super().add_cog(cog)
class Red(RedBase, discord.AutoShardedClient):
"""