Zero6992 / chatGPT-discord-bot

Integrate ChatGPT into your own discord bot
GNU General Public License v2.0
2.67k stars 700 forks source link

discord.app_commands.tree Ignoring exception in command #18

Closed Tsunamori closed 1 year ago

Tsunamori commented 1 year ago

Hi there, I got a error message pop up every time when I send a command to the bot, the log is like this:

2022-12-08 07:50:35 ERROR    discord.app_commands.tree Ignoring exception in command 'chat'
Traceback (most recent call last):
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 862, in _do_call                           
    return await self._callback(interaction, **params)  # type: ignore 
  File "/home/tsunamori/L/chatGPT-discord-bot/src/bot.py", line 47, in chat                                                                   
    await interaction.response.defer(ephemeral = is_private)           
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/interactions.py", line 636, in defer                                       
    await adapter.create_interaction_response(                         
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 218, in request                                   
    raise NotFound(response, data)                                     
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction                                                               

The above exception was the direct cause of the following exception:   

Traceback (most recent call last):                                     
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1242, in _call                                 
    await command._invoke_with_namespace(interaction, namespace)       
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace             
    return await self._do_call(interaction, transformed_values)        
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 880, in _do_call                           
    raise CommandInvokeError(self, e) from e                           
discord.app_commands.errors.CommandInvokeError: Command 'chat' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction 

The code is up-to-date, using the security session to connect the chatGPT. Is there any settings I need to change ?

Zero6992 commented 1 year ago

I have updated a new version and you can try it again. Don't forget to update the related dependencies.

Tsunamori commented 1 year ago

Thanks for the quick update, the error message looks like the same though. I made a pull and give the dependencies an update, discord.py-2.1.0 and revChatGPT-0.0.32.1 at present. Here's the log:

2022-12-08 09:11:20 ERROR    discord.app_commands.tree Ignoring exception in command 'chat'
Traceback (most recent call last):
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 862, in _do_call                           
    return await self._callback(interaction, **params)  # type: ignore 
  File "/home/tsunamori/L/chatGPT-discord-bot/src/bot.py", line 47, in chat                                                                   
    await send_message(interaction, user_message)                      
  File "/home/tsunamori/L/chatGPT-discord-bot/src/bot.py", line 12, in send_message                                                           
    await message.response.defer(ephemeral = is_private)               
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/interactions.py", line 636, in defer                                       
    await adapter.create_interaction_response(                         
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 218, in request                                   
    raise NotFound(response, data)                                     
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction                                                               

The above exception was the direct cause of the following exception:   

Traceback (most recent call last):                                     
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1242, in _call                                 
    await command._invoke_with_namespace(interaction, namespace)       
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace             
    return await self._do_call(interaction, transformed_values)        
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 880, in _do_call                           
    raise CommandInvokeError(self, e) from e                           
discord.app_commands.errors.CommandInvokeError: Command 'chat' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
^C                                                                       
┌──(tsunamori㉿k)-[~/L/chatGPT-discord-bot]
└─$ git rev-parse HEAD
6de74d27f5bf3c17426fd6cd701e75162ceb9e27
Zero6992 commented 1 year ago

Which version of python you are using? I'm trying to reproduce the error you experienced

Tsunamori commented 1 year ago

It's 3.9.13. And for further details, I've update the code to the latest and nothing changed for the error log.

Zero6992 commented 1 year ago

It's 3.9.13. And for further details, I've update the code to the latest and nothing changed for the error log.

So, this issue only happening when sending messages, right?

Can the discord bot be connected correctly?

Tsunamori commented 1 year ago

yep, the bot is connecting to the discord channel and ChatGPT, every time when I send a chat message to the bot(actually each command, chat, private, public, reset, sent to the bot will face this error) it shows up like this:

image

And back to check the terminal running py script, the error log pops up. But if I click the retry button for the sent message in screenshot above, this command will sent to ChatGPT and get the response with no extra warning logs, although for the next message, error shows up again and I need to use the resend button to solve it in a temporary way.

Zero6992 commented 1 year ago

I can't tell you exactly where the issue came from

Unless there are more people encountering the same issue, but I'll keep tracking it

Zero6992 commented 1 year ago

What environment are you running on btw?

Tsunamori commented 1 year ago

Linux k 5.18.0-kali7-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.16-1kali1 (2022-08-31) x86_64 GNU/Linux, it's a debian system, on my local VM. Not pretty sure if the network is the reason of getting error though(using VPN for chatGPT).

Zero6992 commented 1 year ago

The error message may not be the same but I believe it could be related to the tls-client, as mentioned in this issue #21

Tsunamori commented 1 year ago

Make sense to me, I'll have a check later :)

Zero6992 commented 1 year ago

There is an updated version

Noah-Huppert commented 1 year ago

I seem to be having this issue on v0.3.6:

[2022-12-29 08:36:11] [ERROR   ] discord.app_commands.tree: Ignoring exception in command 'chat'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/discord/app_commands/commands.py", line 862, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/DiscordBot/src/bot.py", line 109, in chat
    await send_message(interaction, user_message)
  File "/DiscordBot/src/bot.py", line 21, in send_message
    await message.response.defer(ephemeral=isPrivate)
  File "/usr/local/lib/python3.8/site-packages/discord/interactions.py", line 636, in defer
    await adapter.create_interaction_response(
  File "/usr/local/lib/python3.8/site-packages/discord/webhook/async_.py", line 218, 
in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction      

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/discord/app_commands/tree.py", line 1242, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.8/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/usr/local/lib/python3.8/site-packages/discord/app_commands/commands.py", line 880, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'chat' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

I can't figure out a reliable reproduction. I am running inside of a Docker container built by the Dockerfile in the repository in that tag.