🎨 chore(*): run black to format the code

This commit is contained in:
2023-08-15 12:38:47 +02:00
parent 456e147785
commit 88d65e9f79
4 changed files with 12 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ class Moderation(discord.Cog):
def __init__(self, bot: discord.Bot) -> None: def __init__(self, bot: discord.Bot) -> None:
super().__init__() super().__init__()
self.bot = bot self.bot = bot
""" """
@discord.slash_command( @discord.slash_command(
name="ban", description="Ban a user from using the bot" name="ban", description="Ban a user from using the bot"

View File

@@ -102,7 +102,9 @@ curs_premium.execute(
) )
with open( with open(
os.path.abspath(os.path.join(os.path.dirname(__file__), "./prompts/gpt-3.5-turbo.txt")), os.path.abspath(
os.path.join(os.path.dirname(__file__), "./prompts/gpt-3.5-turbo.txt")
),
"r", "r",
encoding="utf-8", encoding="utf-8",
) as file: ) as file:

View File

@@ -149,9 +149,11 @@ font_matches = {
unsplash_random_image_url = "https://source.unsplash.com/random" unsplash_random_image_url = "https://source.unsplash.com/random"
class FuntionCallError(Exception): class FuntionCallError(Exception):
pass pass
async def get_final_url(url): async def get_final_url(url):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.head(url, allow_redirects=True) as response: async with session.head(url, allow_redirects=True) as response:
@@ -171,7 +173,7 @@ async def do_async_request(url, json=True):
async def add_reaction_to_last_message( async def add_reaction_to_last_message(
message_to_react_to: discord.Message, arguments: dict message_to_react_to: discord.Message, arguments: dict
): ):
emoji = arguments.get("emoji", "") emoji = arguments.get("emoji", "")
if emoji == "": if emoji == "":
raise FuntionCallError("No emoji provided") raise FuntionCallError("No emoji provided")
@@ -204,9 +206,7 @@ async def send_a_stock_image(
await message_in_channel_in_wich_to_send.channel.send(message) await message_in_channel_in_wich_to_send.channel.send(message)
async def create_a_thread( async def create_a_thread(called_by: discord.Message, arguments: dict):
called_by: discord.Message, arguments: dict
):
name = arguments.get("name", "") name = arguments.get("name", "")
if name == "": if name == "":
raise FuntionCallError("No name provided") raise FuntionCallError("No name provided")
@@ -247,7 +247,7 @@ async def send_ascii_art_text(
message = arguments.get("message", "") message = arguments.get("message", "")
if font not in font_matches: if font not in font_matches:
raise FuntionCallError("Invalid font") raise FuntionCallError("Invalid font")
font = font_matches[font] font = font_matches[font]
text = text.replace(" ", "+") text = text.replace(" ", "+")
asciiiar_url = ( asciiiar_url = (
@@ -298,6 +298,7 @@ async def send_ascii_art_image(
message = f"```\n{combo}```\n{message}" message = f"```\n{combo}```\n{message}"
await message_in_channel_in_wich_to_send.channel.send(message) await message_in_channel_in_wich_to_send.channel.send(message)
functions_matching = { functions_matching = {
"add_reaction_to_last_message": add_reaction_to_last_message, "add_reaction_to_last_message": add_reaction_to_last_message,
"reply_to_last_message": reply_to_last_message, "reply_to_last_message": reply_to_last_message,
@@ -306,5 +307,4 @@ functions_matching = {
"send_ascii_art_text": send_ascii_art_text, "send_ascii_art_text": send_ascii_art_text,
"send_ascii_art_image": send_ascii_art_image, "send_ascii_art_image": send_ascii_art_image,
"create_a_thread": create_a_thread, "create_a_thread": create_a_thread,
}
}

View File

@@ -45,9 +45,7 @@ async def fetch_messages_history(channel: discord.TextChannel, limit, original_m
if len(messages) == limit: if len(messages) == limit:
break break
else: else:
async for msg in channel.history( async for msg in channel.history(limit=100, before=original_message):
limit=100, before=original_message
):
if not is_ignorable(msg.content): if not is_ignorable(msg.content):
messages.append(msg) messages.append(msg)
if len(messages) == limit: if len(messages) == limit: