mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[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:
parent
a91cda4995
commit
6082eb21e3
@ -5,8 +5,9 @@ Commands Package
|
||||
================
|
||||
|
||||
This package acts almost identically to :doc:`discord.ext.commands <dpy:ext/commands/api>`; i.e.
|
||||
they both have the same attributes. Some of these attributes, however, have been slightly modified,
|
||||
as outlined below.
|
||||
all of the attributes from discord.py's are also in ours.
|
||||
Some of these attributes, however, have been slightly modified, while others have been added to
|
||||
extend functionlities used throughout the bot, as outlined below.
|
||||
|
||||
.. autofunction:: redbot.core.commands.command
|
||||
|
||||
|
||||
@ -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):
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user