diff --git a/cogs/errors/_cog.py b/cogs/errors/_cog.py index 1e1ecb3c..84e454a5 100644 --- a/cogs/errors/_cog.py +++ b/cogs/errors/_cog.py @@ -33,7 +33,7 @@ async def on_app_command_error( self.bot, i18n.t("errors.bot_missing_perms_title", locale=language), i18n.t("errors.bot_missing_perms", perms=fmt, locale=language), - interaction.guild.id + interaction.guild.id, ) return await interaction.response.send_message( embed=embed, file=file, ephemeral=True @@ -52,7 +52,7 @@ async def on_app_command_error( self.bot, i18n.t("errors.user_missing_perms_title", locale=language), i18n.t("errors.user_missing_perms", perms=fmt, locale=language), - interaction.guild.id + interaction.guild.id, ) return await interaction.response.send_message( embed=embed, file=file, ephemeral=True @@ -63,7 +63,7 @@ async def on_app_command_error( self.bot, i18n.t("errors.cooldown_title", locale=language), i18n.t("errors.cooldown", perms=fmt, locale=language), - interaction.guild.id + interaction.guild.id, ) return await interaction.response.send_message( embed=embed, file=file, ephemeral=True @@ -75,7 +75,7 @@ async def on_app_command_error( self.bot, i18n.t("errors.no_pm_title", locale=language), i18n.t("errors.no_pm", perms=fmt, locale=language), - interaction.guild.id + interaction.guild.id, ) return await interaction.response.send_message( embed=embed, file=file, ephemeral=True @@ -89,7 +89,7 @@ async def on_app_command_error( self.bot, i18n.t("errors.check_failure_title", locale=language), i18n.t("errors.check_failure", perms=fmt, locale=language), - interaction.guild.id + interaction.guild.id, ) return await interaction.response.send_message( embed=embed, file=file, ephemeral=True diff --git a/cogs/misc/autotranslate.py b/cogs/misc/autotranslate.py index 82c90012..cc7eb4cc 100644 --- a/cogs/misc/autotranslate.py +++ b/cogs/misc/autotranslate.py @@ -112,12 +112,14 @@ async def on_message(self, message: discord.Message): if message.attachments: for attachment in message.attachments: bytes = await attachment.read() - attachments.append({ - "bytes": bytes, - "spoiler": attachment.is_spoiler(), - "filename": attachment.filename, - "description": attachment.description - }) + attachments.append( + { + "bytes": bytes, + "spoiler": attachment.is_spoiler(), + "filename": attachment.filename, + "description": attachment.description, + } + ) size = 0 boost_level = message.guild.premium_tier if hasattr(message, "guild") else 0 size_limit = 8000000 @@ -136,7 +138,14 @@ async def on_message(self, message: discord.Message): attachment_removed = True continue attachment_bytes = io.BytesIO(attachment["bytes"]) - new_attachments.append(discord.File(attachment_bytes, spoiler=attachment["spoiler"], filename=attachment["filename"], description=attachment["description"])) + new_attachments.append( + discord.File( + attachment_bytes, + spoiler=attachment["spoiler"], + filename=attachment["filename"], + description=attachment["description"], + ) + ) attachments = new_attachments headers = { "accept": "application/json", @@ -163,7 +172,13 @@ async def on_message(self, message: discord.Message): message.guild.id, ) guild_language = get_language(self.bot, message.guild.id) - too_large_embed, too_large_file = error_embed(self.bot, i18n.t("errors.too_large_title", locale=guild_language), i18n.t("errors.too_large", locale=guild_language), message.guild.id, style="warning") + too_large_embed, too_large_file = error_embed( + self.bot, + i18n.t("errors.too_large_title", locale=guild_language), + i18n.t("errors.too_large", locale=guild_language), + message.guild.id, + style="warning", + ) if confidence >= data["confidence"]: return webhook_id = None @@ -181,7 +196,7 @@ async def on_message(self, message: discord.Message): await webhook.send( username=f"{message.author.display_name} ({data['language']} ➜ {guild_language})", avatar_url=message.author.display_avatar.url, - files = attachments, + files=attachments, embed=discord.Embed( description=await translate( message.content, guild_language @@ -198,7 +213,12 @@ async def on_message(self, message: discord.Message): message.author.mention, embed=too_large_embed, file=too_large_file, - allowed_mentions=discord.AllowedMentions(everyone=False, users=[message.author], roles=False, replied_user=False), + allowed_mentions=discord.AllowedMentions( + everyone=False, + users=[message.author], + roles=False, + replied_user=False, + ), ) return if attachment_removed: @@ -211,7 +231,7 @@ async def on_message(self, message: discord.Message): await webhook.send( username=f"{message.author.display_name} ({data['language']} ➜ {guild_language})", avatar_url=message.author.display_avatar.url, - files = attachments, + files=attachments, content=await translate( message.content, guild_language ), @@ -223,7 +243,12 @@ async def on_message(self, message: discord.Message): message.author.mention, embed=too_large_embed, file=too_large_file, - allowed_mentions=discord.AllowedMentions(everyone=False, users=[message.author], roles=False, replied_user=False), + allowed_mentions=discord.AllowedMentions( + everyone=False, + users=[message.author], + roles=False, + replied_user=False, + ), ) return if attachment_removed: @@ -243,14 +268,19 @@ async def on_message(self, message: discord.Message): ).replace("\n", "\n> ") + f"\n\n` {data['language']} ➜ {guild_language} | {round(data['confidence'])} `", allowed_mentions=discord.AllowedMentions.none(), - files = attachments, + files=attachments, ) if attachment_removed: await message.channel.send( message.author.mention, embed=too_large_embed, file=too_large_file, - allowed_mentions=discord.AllowedMentions(everyone=False, users=[message.author], roles=False, replied_user=False), + allowed_mentions=discord.AllowedMentions( + everyone=False, + users=[message.author], + roles=False, + replied_user=False, + ), ) await message.delete() return @@ -262,7 +292,7 @@ async def on_message(self, message: discord.Message): + f"\n\n` {data['language']} ➜ {guild_language} | {round(data['confidence'])} `", allowed_mentions=discord.AllowedMentions.none(), mention_author=False, - files = attachments, + files=attachments, ) if attachment_removed: await message.reply( diff --git a/utils.py b/utils.py index 4f4086a7..7bee2450 100644 --- a/utils.py +++ b/utils.py @@ -249,7 +249,14 @@ async def balance_embed( return embed, file -def error_embed(bot, title: str, description: str, guild_id: int, footer: str = None, style: str = "error"): +def error_embed( + bot, + title: str, + description: str, + guild_id: int, + footer: str = None, + style: str = "error", +): """tuple[:class:`discord.Embed`, :class:`discord.File`]: Returns an error embed and a file for it's Thumbnail. The first value is the embed and the second value is the file. @@ -262,16 +269,24 @@ def error_embed(bot, title: str, description: str, guild_id: int, footer: str = footer: :class:`str` = "An error occured" The footer of the embed. (Mostly just the translation of "An error occured") style: :class:`str` = "error" - The style of the embed. (Either 'error' or 'warning') + The style of the embed. (Either 'error' or 'warning') """ match style: case "error": file = discord.File("assets/alert.png", filename="thumbnail.png") if not footer: - footer = i18n.t("errors.error_occured", locale=get_language(bot, guild_id)) if not footer else footer + footer = ( + i18n.t("errors.error_occured", locale=get_language(bot, guild_id)) + if not footer + else footer + ) case _: file = discord.File("assets/warning.png", filename="thumbnail.png") - footer = i18n.t("errors.warning_occured", locale=get_language(bot, guild_id)) if not footer else footer + footer = ( + i18n.t("errors.warning_occured", locale=get_language(bot, guild_id)) + if not footer + else footer + ) embed = discord.Embed( title=f"**{title}**", description=description,