Closed japandotorg closed 2 years ago
Thanks for this PR. In order for it to be fully complete, the cogs should take advantage of the benefits that come with asynchronous cog loading. Specifically, the following changes also need to be made:
cog_unload
method that calls asyncio.create_task
should be made asynchronous and await
the coroutine rather than creating a task. For example, in aki/aki.py
at line 65,
def cog_unload(self):
asyncio.create_task(self.session.close())
should become
async def cog_unload(self):
await self.session.close()
cog_load
instead which is implicitly called instead. For example, in baron/__init__.py
at line 39, await cog.build_cache()
should be removed and build_cache
should be renamed to cog_load
at baron/baron.py
at line 95.If you have questions about making these changes, feel free to ask in a comment.
sure, thanks for informing me, i'll start addressing them as soon as i'm on my pc and yes i'll post a comment if i need any help or whatsoever
After checking all the files thoroughly i have awaited all the coroutines and all the possible stuff that needed to be made asynchronous ( where i felt it was the right thing to do ), and I guess this is it for now, let me know if anything else needs a change or whatsoever.
alright ty for pointing out all the stuff, i'll change them right away and test them
i'll start testing all the changes now
so the TagScriptEngine lib needs changes to be made.
this was invoked when testing the customping cog, was working fine before making the cog_load
change.
AttributeError: 'Member' object has no attribute 'avatar_url'
Ignoring exception in command tree:
Traceback (most recent call last):
File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 881, in wrapper
await self.call(interaction)
File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1020, in call
command, options = self._get_app_command_options(data)
File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 911, in _get_app_command_options
raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'ping' not found
Ignoring exception in view <ConfirmationView timeout=60 children=2> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=True label='No' emoji=None row=None>:
Traceback (most recent call last):
File "/root/env/lib/python3.9/site-packages/discord/ui/view.py", line 413, in _scheduled_task
await item.callback(interaction)
File "/root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/slashtags/views.py", line 108, in no
await self.disable_all(button, interaction)
File "/root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/slashtags/views.py", line 115, in disable_all
await interaction.response.edit_message(view=self)
AttributeError: 'Button' object has no attribute 'response'
[08:26:05] CRITICAL [red.main] Caught unhandled exception in <Task finished name='discord-ui-view-timeout-2e45611ecbe546b2fc67c08cbc5c188a' coro=<ConfirmationView.on_timeout() done, defined at /root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/slashtags/views.py:117> exception=NotFound('404 Not Found (error code: 10008): Unknown Message')>:
Task exception was never retrieved
╭───────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────╮
│ /root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/slashtags/views.py:119 in on_timeout │
│ ❱ 119 await self.message.edit(view=self) │
│ /root/env/lib/python3.9/site-packages/discord/message.py:1984 in edit │
│ ❱ 1984 data = await self._state.http.edit_message(self.channel.id, self.id, │
│ params=params) │
│ /root/env/lib/python3.9/site-packages/discord/http.py:493 in request │
│ ❱ 493 raise NotFound(response, data) │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
NotFound: 404 Not Found (error code: 10008): Unknown Message
Ignoring exception in command tree:
Traceback (most recent call last):
File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 881, in wrapper
await self.call(interaction)
File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1020, in call
command, options = self._get_app_command_options(data)
File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 911, in _get_app_command_options
raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'hi' not found
this is the error for slashtags
Okay so after extensive use of my single braincell I've fixed whatever I could and tested each and every cog + the sub commands, and all that is left are the tags and slashtags cog ( TagScriptEngine lib related ) and the customping cog.
so the TagScriptEngine lib needs changes to be made.
These changes have already been made, you need to install the dpy2 branch instead.
The dpy2 branch of TagScriptEngine??
Ignoring exception in command tree: Traceback (most recent call last): File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 881, in wrapper await self.call(interaction) File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1020, in call command, options = self._get_app_command_options(data) File "/root/env/lib/python3.9/site-packages/discord/app_commands/tree.py", line 911, in _get_app_command_options raise CommandNotFound(name, parents) discord.app_commands.errors.CommandNotFound: Application command 'hi' not found
this is the error for slashtags
Do slashtags still work when invoked? As far as I can tell, this error should only be logged implicitly but won't prevent slashtags from being invoked. I'm going to fix it at a later date.
Ignoring exception in view <AkiView timeout=60 children=8> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='yes' emoji=None row=None>: Traceback (most recent call last): File "/root/env/lib/python3.9/site-packages/discord/ui/view.py", line 413, in _scheduled_task await item.callback(interaction) File "/root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/aki/views.py", line 44, in yes await self.answer_question("yes", interaction) File "/root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/aki/views.py", line 87, in answer_question await self.send_current_question(interaction) File "/root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/aki/views.py", line 167, in send_current_question await self.edit(interaction) File "/root/.local/share/Red-DiscordBot/data/esdeath/cogs/CogManager/cogs/aki/views.py", line 156, in edit await interaction.message.edit(embed=self.current_question_embed(), view=self) AttributeError: 'Button' object has no attribute 'message'
fixed the error for aki
I forgot about this change, can you go through all view callbacks in the repo and change the signature from (self, button: discord.ui.Button, interaction: discord.Interaction)
to `(self, interaction: discord.Interaction, button: discord.ui.Button)?
The dpy2 branch of TagScriptEngine??
Yeah, but that's unrelated to this PR.
Do slashtags still work when invoked? As far as I can tell, this error should only be logged implicitly but won't prevent slashtags from being invoked. I'm going to fix it at a later date.
nope it doesn't for some reason, thought it would be bc of the lib, but I guess I'm wrong here.
I forgot about this change, can you go through all view callbacks in the repo and change the signature from
(self, button: discord.ui.Button, interaction: discord.Interaction)
to `(self, interaction: discord.Interaction, button: discord.ui.Button)?
Sure, i'll address them and do it right away.
Thanks for making the changes I asked for throughout this PR!
So uhh the dpy2 wasn't working for my
dpy2_unstable
branch of red and then i figured that it was bc the extensions weren't awaited, this PR will address those changes for thedpy2_unstable
branch of red, had to have it done bc phen-cogs being the most used red-cog at the momentdpy2_unstable
branch