Unknown interaction errors
Kav-K opened this issue ยท 11 comments
Sometimes there are unknown interaction errors with a response in /gpt converse takes too long to return, or if the user deleted their original message it is responding to before it responds
Would something like:
try:
interaction.respond(*args, **kwargs)
except DiscorUnknownErrorClass: #Interaction not found, reply instead
try:
interaction.message.reply(*args, **kwargs)
except DiscordNotFoundErrorClass: #Message not found, mention the user instead
content = kwargs.get(content, "")
content = interaction.user.mention + "\n" + content
kwargs["content"] = content
interaction.channel.send(*args, **kwargs)
Work?
Not suer about the kwargs syntax, that's just to showcase.
I can probably do a pr if that's what's wanted
@Paillat-dev sure! That would be appreciated, I'm not sure exactly where the errors are though but making any uncaught interaction.respond's safer should work generally
I noticed something while digging into this, gpt_converse passes to encapsulated_send a "discord.Message" in the ctx parameter. Dosen't impact anything here but found that interesting.
@Kav-K I think it's best if you keep this upen until it's certain that no errors occur anymore
@Paillat-dev
I had to revert your PR, there were issues
root@lab:/home/kaveen/GPTDiscord# python3.9 gpt3discord.py
Loading environment from .env
Loading environment from /home/kaveen/GPTDiscord/etc/environment
Loading environment from None
Attempting to retrieve the settings DB
Retrieved the settings DB
Traceback (most recent call last):
File "/home/kaveen/GPTDiscord/gpt3discord.py", line 14, in <module>
from cogs.code_interpreter_service_cog import CodeInterpreterService
File "/home/kaveen/GPTDiscord/cogs/code_interpreter_service_cog.py", line 38, in <module>
from utils.safe_ctx_respond import safe_ctx_respond
ModuleNotFoundError: No module named 'utils'
root@lab:/home/kaveen/GPTDiscord# python3.9 gpt3discord.py
Loading environment from .env
Loading environment from /home/kaveen/GPTDiscord/etc/environment
Loading environment from None
Attempting to retrieve the settings DB
Retrieved the settings DB
Traceback (most recent call last):
File "/home/kaveen/GPTDiscord/gpt3discord.py", line 14, in <module>
from cogs.code_interpreter_service_cog import CodeInterpreterService
File "/home/kaveen/GPTDiscord/cogs/code_interpreter_service_cog.py", line 38, in <module>
from cogs.utils.safe_ctx_respond import safe_ctx_respond
File "/home/kaveen/GPTDiscord/cogs/utils/safe_ctx_respond.py", line 5, in <module>
*args: discord.ApplicationContext.respond.args,
AttributeError: 'function' object has no attribute 'args'
root@lab:/home/kaveen/GPTDiscord#
I'll setup that myself and test all of the commands, and fix any errors ๐.
@Paillat-dev Still issues with your PR
Retrieved the settings DB
Traceback (most recent call last):
File "/home/kaveen/GPTDiscord/gpt3discord.py", line 14, in <module>
from cogs.code_interpreter_service_cog import CodeInterpreterService
File "/home/kaveen/GPTDiscord/cogs/code_interpreter_service_cog.py", line 38, in <module>
from utils.safe_ctx_respond import safe_ctx_respond
File "/home/kaveen/GPTDiscord/utils/safe_ctx_respond.py", line 3, in <module>
async def safe_ctx_respond(*args: discord.ApplicationContext.respond.args, **kwargs: discord.ApplicationContext.respond.kwargs) -> None:
AttributeError: 'function' object has no attribute 'args'
root@lab:/home/kaveen/GPTDiscord#
@Paillat-dev Still issues with your PR
Retrieved the settings DB Traceback (most recent call last): File "/home/kaveen/GPTDiscord/gpt3discord.py", line 14, in <module> from cogs.code_interpreter_service_cog import CodeInterpreterService File "/home/kaveen/GPTDiscord/cogs/code_interpreter_service_cog.py", line 38, in <module> from utils.safe_ctx_respond import safe_ctx_respond File "/home/kaveen/GPTDiscord/utils/safe_ctx_respond.py", line 3, in <module> async def safe_ctx_respond(*args: discord.ApplicationContext.respond.args, **kwargs: discord.ApplicationContext.respond.kwargs) -> None: AttributeError: 'function' object has no attribute 'args' root@lab:/home/kaveen/GPTDiscord#
I had fixed that, it was because of the type hintings, and I opened another pr for it. Anyways, I see that you put it with only CTX and content as args
It was on #390 that I had fixed it.