Closed KosmicAnomaly closed 2 years ago
Can you try with discord.Cog? Also, are you using commands.Bot or discord.Bot?
Can you try with discord.Cog? Also, are you using commands.Bot or discord.Bot?
Seems like this only happens when using discord.Bot, as it does not implement add_listener. commands.Bot however does implement add_listener and it works without issues.
should they be implemented into discord.Bot?
Seems like this only happens when using discord.Bot, as it does not implement add_listener. commands.Bot however does implement add_listener and it works without issues.
should they be implemented into discord.Bot?
This is more of a bug, considering discord.Cog.listener
is implemented but only works with commands.Bot
.
Seems like this only happens when using discord.Bot, as it does not implement add_listener. commands.Bot however does implement add_listener and it works without issues. should they be implemented into discord.Bot?
This is more of a bug, considering
discord.Cog.listener
is implemented but only works withcommands.Bot
.
I agree, just didn't want to work on something that may not be merged. cause how was this not caught in discord.py originally lol
discord.Cog
does not exist in discord.py
Summary
We currently are unable to setup listeners in Cogs
Reproduction Steps
Try to setup a listener in a Cog
Minimal Reproducible Code
Expected Results
Have a functioning listener
Actual Results
Traceback (most recent call last): File "C:\Users\foobar\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\cog.py", line 668, in _load_from_module_spec setup(self) File "C:\Users\foobar\Desktop\Code\DiscordBots\BlackHole\Modules\Fun\Palindrome.py", line 36, in setup bot.add_cog(Palindrome(bot)) File "C:\Users\foobar\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\cog.py", line 550, in add_cog cog = cog._inject(self) File "C:\Users\foobar\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\cog.py", line 474, in _inject bot.add_listener(getattr(self, method_name), name) AttributeError: 'Bot' object has no attribute 'add_listener'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\foobar\Desktop\Code\DiscordBots\BlackHole\Bot.py", line 89, in
BlackHole.load_extension(fullpath[:-3])
File "C:\Users\foobar\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\cog.py", line 728, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\cog.py", line 671, in _load_from_module_spec
self._remove_module_references(lib.name)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\cog.py", line 617, in _remove_module_references
for cmd in self.all_commands.copy().values():
AttributeError: 'Bot' object has no attribute 'all_commands'
Intents
discord.Intents.all()
System Information
Checklist
Additional Context
No response