Custom text error incase api key is expired or got rate limiter

Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
This commit is contained in:
Yasir Aris M 2024-02-11 21:46:02 +07:00 committed by GitHub
parent c879c510f4
commit 8fe69d3457
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,7 +108,9 @@ async def openai_chatbot(_, ctx: Message, strings):
except APIConnectionError as e: except APIConnectionError as e:
await msg.edit_msg(f"The server could not be reached because {e.__cause__}") await msg.edit_msg(f"The server could not be reached because {e.__cause__}")
except RateLimitError as e: except RateLimitError as e:
await msg.edit_msg("A 429 status code was received; we should back off a bit.") if "billing details" in e:
return await msg.edit_msg("This openai key from this bot has expired, please give openai key donation for bot owner.")
await msg.edit_msg("You're got rate limit, please try again later.")
except APIStatusError as e: except APIStatusError as e:
await msg.edit_msg(f"Another {e.status_code} status code was received with response {e.response}") await msg.edit_msg(f"Another {e.status_code} status code was received with response {e.response}")
except Exception as e: except Exception as e: