mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
🐛 fix(ChatProcess.py): handle APIError separately in error handling logic to provide a specific error message when OpenAI API is not working
🐛 fix(ChatProcess.py): improve error handling logic to provide a more informative error message when an error occurs while processing a message
This commit is contained in:
@@ -5,6 +5,7 @@ import discord
|
|||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from openai.error import APIError
|
||||||
from src.utils.misc import moderate
|
from src.utils.misc import moderate
|
||||||
from src.utils.variousclasses import models, characters
|
from src.utils.variousclasses import models, characters
|
||||||
from src.guild import Guild
|
from src.guild import Guild
|
||||||
@@ -209,6 +210,12 @@ class Chat:
|
|||||||
self.message.remove_reaction("🤔", self.message.guild.me)
|
self.message.remove_reaction("🤔", self.message.guild.me)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if isinstance(e, APIError):
|
||||||
|
await self.message.channel.send(
|
||||||
|
"Due to OpenAI not doing their work, I can unfortunately not answer right now. Do retry soon!",
|
||||||
|
delete_after=5,
|
||||||
|
)
|
||||||
|
else:
|
||||||
await self.message.channel.send(
|
await self.message.channel.send(
|
||||||
f"""An error occured while processing your message, we are sorry about that. Please check your settings and try again later. If the issue persists, please join uor discord server here: https://discord.gg/pB6hXtUeDv and send the following logs:
|
f"""An error occured while processing your message, we are sorry about that. Please check your settings and try again later. If the issue persists, please join uor discord server here: https://discord.gg/pB6hXtUeDv and send the following logs:
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user