mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
11
main.py
11
main.py
@@ -20,12 +20,21 @@ bot.add_cog(cogs.Moderation(bot))
|
|||||||
async def on_ready():
|
async def on_ready():
|
||||||
await bot.change_presence(
|
await bot.change_presence(
|
||||||
activity=discord.Activity(
|
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")
|
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
|
@bot.event
|
||||||
async def on_application_command_error(ctx, error):
|
async def on_application_command_error(ctx, error):
|
||||||
debug(error)
|
debug(error)
|
||||||
|
|||||||
@@ -205,10 +205,8 @@ async def send_a_gif(
|
|||||||
):
|
):
|
||||||
query = query.replace(" ", "+")
|
query = query.replace(" ", "+")
|
||||||
image_url = f"{tenor_api_url}{query}&limit={limit}"
|
image_url = f"{tenor_api_url}{query}&limit={limit}"
|
||||||
print(image_url)
|
|
||||||
response = await do_async_request(image_url)
|
response = await do_async_request(image_url)
|
||||||
json = response
|
json = response
|
||||||
print(json)
|
|
||||||
gif_url = random.choice(json["results"])["itemurl"] # type: ignore
|
gif_url = random.choice(json["results"])["itemurl"] # type: ignore
|
||||||
message = message + "\n" + gif_url
|
message = message + "\n" + gif_url
|
||||||
await message_in_channel_in_wich_to_send.channel.send(message)
|
await message_in_channel_in_wich_to_send.channel.send(message)
|
||||||
|
|||||||
@@ -169,6 +169,14 @@ async def chatgpt_process(
|
|||||||
"The function call is empty. Please retry.", delete_after=10
|
"The function call is empty. Please retry.", delete_after=10
|
||||||
)
|
)
|
||||||
else:
|
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
|
await message.channel.send(response["content"]) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class openai_caller:
|
|||||||
f"\n\n{bcolors.BOLD}{bcolors.WARNING}APIError. This is not your fault. Retrying...{bcolors.ENDC}"
|
f"\n\n{bcolors.BOLD}{bcolors.WARNING}APIError. This is not your fault. Retrying...{bcolors.ENDC}"
|
||||||
)
|
)
|
||||||
await recall_func(
|
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 asyncio.sleep(10)
|
||||||
await recall_func()
|
await recall_func()
|
||||||
|
|||||||
Reference in New Issue
Block a user