From f222aedd778ecb5dcc285fe9a2ed80e9eca8462d Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 11 Aug 2023 16:31:35 -0400 Subject: [PATCH] fix: fixed logging being disabled if dms were disabled --- shortmute/shortmute.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/shortmute/shortmute.py b/shortmute/shortmute.py index 0ae46a9..073ea65 100644 --- a/shortmute/shortmute.py +++ b/shortmute/shortmute.py @@ -103,15 +103,15 @@ class Shortmute(commands.Cog): await target.send(embed=dm_embed) except discord.HTTPException as error: await message.edit(content="Could not message the target, user most likely has Direct Messages disabled.") - logging_channels_list = await self.config.guild(interaction.guild).logging_channels() - if logging_channels_list: - logging_embed = discord.Embed(title="User Shortmuted", description=f"**Moderator:** {interaction.user.mention} ({interaction.user.id})\n**Target:** {target.mention} ({target.id})\n**Duration:** {readable_duration}\n**Reason:** `{reason}`\n**Confirmation Skipped:** True", color=await self.bot.get_embed_color(None)) - logging_embed.set_footer(text="/shortmute") - if evidence: - logging_embed.set_image(url=evidence) - for channel_id in logging_channels_list: - channel_obj = interaction.guild.get_channel(channel_id) - await channel_obj.send(embed=logging_embed) + logging_channels_list = await self.config.guild(interaction.guild).logging_channels() + if logging_channels_list: + logging_embed = discord.Embed(title="User Shortmuted", description=f"**Moderator:** {interaction.user.mention} ({interaction.user.id})\n**Target:** {target.mention} ({target.id})\n**Duration:** {readable_duration}\n**Reason:** `{reason}`\n**Confirmation Skipped:** True", color=await self.bot.get_embed_color(None)) + logging_embed.set_footer(text="/shortmute") + if evidence: + logging_embed.set_image(url=evidence) + for channel_id in logging_channels_list: + channel_obj = interaction.guild.get_channel(channel_id) + await channel_obj.send(embed=logging_embed) class ShortmuteButtons(ui.View): def __init__(self, timeout, passed_info: dict): @@ -145,15 +145,15 @@ class Shortmute(commands.Cog): await target.send(embed=dm_embed) except discord.HTTPException as error: await old_message.edit(content="Could not message the target, user most likely has Direct Messages disabled.") - logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels() - if logging_channels_list: - logging_embed = discord.Embed(title="User Shortmuted", description=f"**Moderator:** {old_interaction.user.mention} ({old_interaction.user.id})\n**Target:** {target.mention} ({target.id})\n**Duration:** {readable_duration}\n**Reason:** `{reason}`\n**Confirmation Skipped:** False", color=color) - logging_embed.set_footer(text="/shortmute") - if evidence: - logging_embed.set_image(url=evidence) - for channel_id in logging_channels_list: - channel_obj = old_interaction.guild.get_channel(channel_id) - await channel_obj.send(embed=logging_embed) + logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels() + if logging_channels_list: + logging_embed = discord.Embed(title="User Shortmuted", description=f"**Moderator:** {old_interaction.user.mention} ({old_interaction.user.id})\n**Target:** {target.mention} ({target.id})\n**Duration:** {readable_duration}\n**Reason:** `{reason}`\n**Confirmation Skipped:** False", color=color) + logging_embed.set_footer(text="/shortmute") + if evidence: + logging_embed.set_image(url=evidence) + for channel_id in logging_channels_list: + channel_obj = old_interaction.guild.get_channel(channel_id) + await channel_obj.send(embed=logging_embed) @ui.button(label="No", style=discord.ButtonStyle.danger) async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction):