Merge pull request #49 from Paillat-dev/dev

Dev
This commit is contained in:
2023-08-02 10:59:02 +02:00
committed by GitHub
4 changed files with 19 additions and 4 deletions

11
main.py
View File

@@ -20,12 +20,21 @@ bot.add_cog(cogs.Moderation(bot))
async def on_ready():
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching, name="your messages to answer you"
type=discord.ActivityType.watching, name=f"{len(bot.guilds)} servers"
)
)
debug("Bot is ready")
@bot.event
async def on_guild_join(guild):
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching, name=f"{len(bot.guilds)} servers"
)
)
@bot.event
async def on_application_command_error(ctx, error):
debug(error)

View File

@@ -205,10 +205,8 @@ async def send_a_gif(
):
query = query.replace(" ", "+")
image_url = f"{tenor_api_url}{query}&limit={limit}"
print(image_url)
response = await do_async_request(image_url)
json = response
print(json)
gif_url = random.choice(json["results"])["itemurl"] # type: ignore
message = message + "\n" + gif_url
await message_in_channel_in_wich_to_send.channel.send(message)

View File

@@ -169,6 +169,14 @@ async def chatgpt_process(
"The function call is empty. Please retry.", delete_after=10
)
else:
content = response.get("content", "")
while len(content) != 0:
if len(content) > 2000:
await message.channel.send(content[:2000])
content = content[2000:]
else:
await message.channel.send(content)
content = ""
await message.channel.send(response["content"]) # type: ignore

View File

@@ -123,7 +123,7 @@ class openai_caller:
f"\n\n{bcolors.BOLD}{bcolors.WARNING}APIError. This is not your fault. Retrying...{bcolors.ENDC}"
)
await recall_func(
"`An APIError occurred. This is not your fault. Retrying...`"
"`An APIError occurred. This is not your fault, it is OpenAI's fault. We apologize for the inconvenience. Retrying...`"
)
await asyncio.sleep(10)
await recall_func()