Open tesence opened 5 years ago
Can reproduce... sort of. Since this is an old error, had to convert to the new Cog style, just subclassing commands.Cog
worked fine.
- Python v3.7.3-final
- discord.py v1.2.0-alpha -- 007b7eb
- discord.py pkg_resources: v1.0.0a1718+g42a7c4f
- aiohttp v3.5.4
- websockets v6.0
- system info: Windows 10 10.0.18362
cog.py
loaded first, then cog2.py
.
Invoked command: hello_world2
cog2.py
loaded first, thencog.py
.
Invoked command: hello_world
CR.
When loading cog.py
first, then cog2.py
, invoking the default help command prints "Invoked command: hello_world".
When loading cog2.py
first, then cog.py
, invoking the default help command prints "Invoked command: hello_world2".
my findings have shown that:
this stashing of the current instance causes issues https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L1232-L1233
as the command is never reset at https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L1252
then a race condition can occur when the help command invokes can_run
on each command
If you use the decorator
@commands.is_owner()
(and maybe other decorators aswell), on a command defined in a cog and you print the value ofctx.command.name
inon_command
as followand invoke the default
help
command,on_command
will pint the name of the command using that check that has been loaded the first.Minimal test case (tested on rewrite, not async)
main.py
class Bot(commands.Bot):
bot = Bot(command_prefix="!") bot.load_extension("cog") bot.load_extension("cog2") bot.run("")
from discord.ext import commands
class HelloWorldCog:
def setup(bot): bot.add_cog(HelloWorldCog(bot))
from discord.ext import commands
class HelloWorldCog2:
def setup(bot): bot.add_cog(HelloWorldCog2(bot))
bot.load_extension("cog") bot.load_extension("cog2")
bot.load_extension("cog2") bot.load_extension("cog")