Closed Kuchenmampfer closed 2 years ago
This exception originated from your cog's __init__
method, and is not a problem with the library:
File "/home/discordbots/Uebot/cogs/Fun/textbefehle.py", line 19, in __init__ self.commands_dict = asyncio.get_event_loop().run_until_complete(self.load_commands())
The rest of the exception was from
asyncio
, a result of you trying to run something in an already running event loop, and the library trying it's best to handle it and raise the proper exception, which it did.
This exception originated from your cog's
__init__
method, and is not a problem with the library:File "/home/discordbots/Uebot/cogs/Fun/textbefehle.py", line 19, in __init__ self.commands_dict = asyncio.get_event_loop().run_until_complete(self.load_commands())
The rest of the exception was from
asyncio
, a result of you trying to run something in an already running event loop, and the library trying it's best to handle it and raise the proper exception, which it did.
I'm guessing the solution is add a task to loop of the running bot, Something like this:
self.loop = ... # get the event loop of the bot
self.commands_dict = self.loop.create_task(self.load_commands())
I don't think this will work so I rather say this is not preferred
This exception originated from your cog's
__init__
method, and is not a problem with the library:File "/home/discordbots/Uebot/cogs/Fun/textbefehle.py", line 19, in __init__ self.commands_dict = asyncio.get_event_loop().run_until_complete(self.load_commands())
The rest of the exception was from
asyncio
, a result of you trying to run something in an already running event loop, and the library trying it's best to handle it and raise the proper exception, which it did.I'm guessing the solution is add a task to loop of the running bot, Something like this:
self.loop = ... # get the event loop of the bot self.commands_dict = self.loop.create_task(self.load_commands())
I don't think this will work so I rather say this is not preferred
I do not care what your solution is, this is not a problem with the library.
This exception originated from your cog's
__init__
method, and is not a problem with the library:File "/home/discordbots/Uebot/cogs/Fun/textbefehle.py", line 19, in __init__ self.commands_dict = asyncio.get_event_loop().run_until_complete(self.load_commands())
The rest of the exception was from
asyncio
, a result of you trying to run something in an already running event loop, and the library trying it's best to handle it and raise the proper exception, which it did.I'm guessing the solution is add a task to loop of the running bot, Something like this:
self.loop = ... # get the event loop of the bot self.commands_dict = self.loop.create_task(self.load_commands())
I don't think this will work so I rather say this is not preferred
I do not care what your solution is, this is not a problem with the library.
Alr
Oh you are right. I thought I had it with different cogs too and when I asked on the support discord, they, like me, guessed it was a lib issue. But apparently the other ones work well and I just need to improve my traceback reading skills. Thank you for your help and sorry for falsely opening this issue.
Summary
reloading a cog with a slash command in it throws RuntimeError
Reproduction Steps
I created a cog with at least one slash command in it and loaded it in the init function of my bot. In another cog, I have a text command that is supposed to reload any specified cog. It works fine when the reloaded cog only has text commands in it, but when it contains at least one slash command, reloading fails and I get
RuntimeError: This event loop is already running
.Minimal Reproducible Code
Expected Results
I expect this command to reload the specified cog and update its commands in case I changed them. So basically I expect it to behave as it does when the cog only contains text commands.
Actual Results
Instead, the cog gets unloaded, but loading it again fails with the following traceback:
Intents
I use Intents.all()
System Information
I also tested it on
py-cord v2.0.0b4
and got the same behaviour.Checklist
Additional Context
No response