Zero6992 / chatGPT-discord-bot

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

Chat prompts in the one channel the bot has access to stops working if a chat prompt is initiated from a channel it does not have access to #518

Open SirFrostingham opened 2 weeks ago

SirFrostingham commented 2 weeks ago

Steps:

  1. Chat in the channel the bot has access to (it works fine)
  2. Chat in a channel on the Discord server it does not have access to (it throws a 403 Forbidden exception on the chat bot server)
  3. Go back to the channel the bot has access to
  4. Send another chat prompt

Result: The chat bot stops working. On the server, the message is registered and the requests stop sending responses to the Discord channel it has access to. Sending messages works, but replies stop working until the chat bot server is restarted.

2024-06-16 09:13:29 INFO     src.log -> Send system prompt with size 11
INFO:src.log:Send system prompt with size 11
2024-06-16 09:13:31 INFO     src.log -> System prompt response: Hello! How can I assist you today?
INFO:src.log:System prompt response: Hello! How can I assist you today?
2024-06-16 09:13:31 INFO     src.log -> MoosepuncherChatGpt#8755 is now running!
INFO:src.log:MoosepuncherChatGpt#8755 is now running!
2024-06-16 09:13:51 INFO     src.log -> terdfergasen : /chat [hey siri] in (�💬general-cha
INFO:src.log:terdfergasen : /chat [hey siri] in (�💬general-cha
2024-06-16 09:17:41 INFO     src.log -> terdfergasen : /chat [tell me a paragram story about how awesome i am] in (�💬general-cha
INFO:src.log:terdfergasen : /chat [tell me a paragram story about how awesome i am] in (�💬general-cha
2024-06-16 09:20:40 INFO     src.log -> terdfergasen : '/switchpersona [dan]' (test)
INFO:src.log:terdfergasen : '/switchpersona [dan]' (test)
2024-06-16 09:20:41 INFO     src.log -> Send system prompt with size 11
2024-06-16 09:20:43 INFO     src.log -> System prompt response: Hello! How can I assist you today?
2024-06-16 09:28:45 INFO     src.log -> terdfergasen : /chat [what game servers are currently running?] in (test)
INFO:src.log:terdfergasen : /chat [what game servers are currently running?] in (test)
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-14' coro=<discordClient.process_messages() done, defined at D:\source\chatGPT-discord-bot\src\aclient.py:51> exception=Forbidden('403 Forbidden (error code: 50001): Missing Access')>
Traceback (most recent call last):
  File "D:\source\chatGPT-discord-bot\src\aclient.py", line 55, in process_messages
    async with self.current_channel.typing():
  File "C:\Users\aaron\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\context_managers.py", line 82, in __aenter__
    await channel._state.http.send_typing(channel.id)
  File "C:\Users\aaron\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 739, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
2024-06-16 09:37:20 INFO     src.log -> terdfergasen : /chat [what's the significance of today?] in (test)
INFO:src.log:terdfergasen : /chat [what's the significance of today?] in (test))
2024-06-16 09:38:50 INFO     src.log -> terdfergasen : /chat [in a couple of sentences, tell me how dumb i am] in (�💬general-chat)
INFO:src.log:terdfergasen : /chat [in a couple of sentences, tell me how dumb i am] in (�💬general-chat)
SirFrostingham commented 2 weeks ago

Maybe there is a way to enable server-wide Discord channel chat/reply? Maybe that could be a workaround.

Cool code/bot! Thanks for making this!