diff --git a/moderation/embed_factory.py b/moderation/embed_factory.py index 6d2160b..2fd136f 100644 --- a/moderation/embed_factory.py +++ b/moderation/embed_factory.py @@ -8,7 +8,7 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact Valid arguments for 'embed_type': - 'message' - - 'log' - WIP + - 'log' - 'case' - 'changes' diff --git a/moderation/moderation.py b/moderation/moderation.py index 12c9af1..0441eec 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -204,7 +204,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'NOTE', target.id, 0, 'NULL', reason) await interaction.edit_original_response(content=f"{target.mention} has received a note! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) @app_commands.command(name="warn") async def warn(self, interaction: discord.Interaction, target: discord.Member, reason: str, silent: bool = None): @@ -234,7 +234,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'WARN', target.id, 0, 'NULL', reason) await interaction.edit_original_response(content=f"{target.mention} has been warned! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) async def blacklist_autocomplete(self, interaction: discord.Interaction, current: str,) -> list[app_commands.Choice[str]]: # pylint: disable=unused-argument """Autocompletes a blacklist role.""" @@ -298,7 +298,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'BLACKLIST', target.id, role, matching_role['duration'], reason) await interaction.edit_original_response(content=f"{target.mention} has been blacklisted with the {role_obj.name} role for {humanize.precisedelta(matching_role['duration'])}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) @app_commands.command(name="mute") async def mute(self, interaction: discord.Interaction, target: discord.Member, duration: str, reason: str, silent: bool = None): @@ -346,7 +346,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'MUTE', target.id, 0, parsed_time, reason) await interaction.edit_original_response(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) @app_commands.command(name="unmute") async def unmute(self, interaction: discord.Interaction, target: discord.Member, reason: str = None, silent: bool = None): @@ -386,7 +386,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'UNMUTE', target.id, 0, 'NULL', reason) await interaction.edit_original_response(content=f"{target.mention} has been unmuted! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) @app_commands.command(name="kick") async def kick(self, interaction: discord.Interaction, target: discord.Member, reason: str, silent: bool = None): @@ -418,7 +418,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'KICK', target.id, 0, 'NULL', reason) await interaction.edit_original_response(content=f"{target.mention} has been kicked! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) @app_commands.command(name="ban") @app_commands.choices(delete_messages=[ @@ -473,7 +473,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'TEMPBAN', target.id, 0, parsed_time, reason) await interaction.edit_original_response(content=f"{target.mention} has been banned for {humanize.precisedelta(parsed_time)}! (Case `#{moderation_id}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) else: await interaction.response.send_message(content=f"{target.mention} has been banned!\n**Reason** - `{reason}`") @@ -532,7 +532,7 @@ class Moderation(commands.Cog): moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 0, 'NULL', reason) await interaction.edit_original_response(content=f"{target.mention} has been unbanned! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") - await log(interaction, moderation_id, await self.bot.get_embed_color(None)) + await log(interaction, moderation_id) @app_commands.command(name="history") async def history(self, interaction: discord.Interaction, target: discord.User = None, moderator: discord.User = None, pagesize: app_commands.Range[int, 1, 20] = None, page: int = 1, ephemeral: bool = None, inline: bool = None, export: bool = False): @@ -764,7 +764,7 @@ class Moderation(commands.Cog): embed = await embed_factory('case', await self.bot.get_embed_color(None), interaction=interaction, case_dict=await self.fetch_case(case, interaction.guild.id)) await interaction.response.send_message(content=f"✅ Moderation #{case:,} resolved!", embed=embed) - await log(interaction, case, await self.bot.get_embed_color(None), True) + await log(interaction, case) cursor.close() database.close() @@ -926,7 +926,7 @@ class Moderation(commands.Cog): embed = await embed_factory('case', await self.bot.get_embed_color(None), interaction=interaction, case_dict=new_case) await interaction.response.send_message(content=f"✅ Moderation #{case:,} edited!", embed=embed, ephemeral=True) - await log(interaction, case, await self.bot.get_embed_color(None)) + await log(interaction, case) cursor.close() database.close() @@ -963,7 +963,7 @@ class Moderation(commands.Cog): try: await guild.unban(user, reason=f"Automatic unban from case #{moderation_id}") - embed = await embed_factory('message', guild, f'Automatic unban from case #{moderation_id}', 'unbanned') + embed = await embed_factory('message', self.bot.get_embed_color(None), guild, f'Automatic unban from case #{moderation_id}', 'unbanned') try: await user.send(embed=embed) diff --git a/moderation/utils.py b/moderation/utils.py index af273fc..0de3dd4 100644 --- a/moderation/utils.py +++ b/moderation/utils.py @@ -180,7 +180,7 @@ async def fetch_role_dict(interaction: Interaction, role_id: str): return role_dict -async def log(interaction: Interaction, moderation_id: int, color: Color, resolved: bool = False): +async def log(interaction: Interaction, moderation_id: int, resolved: bool = False): """This method sends a message to the guild's configured logging channel when an infraction takes place.""" from .embed_factory import embed_factory @@ -191,7 +191,7 @@ async def log(interaction: Interaction, moderation_id: int, color: Color, resolv case = await fetch_case(moderation_id, interaction.guild.id) if case: embed = await embed_factory( - "log", color, interaction=interaction, case_dict=case, resolved=resolved + "log", interaction.client.get_embed_color(None), interaction=interaction, case_dict=case, resolved=resolved ) try: await logging_channel.send(embed=embed)