From 6997f2308893b6869ad6f431f72ccd046a806cac Mon Sep 17 00:00:00 2001 From: FrozenChen Date: Thu, 10 Oct 2024 00:59:32 -0300 Subject: [PATCH] kickban.py: Fix ban slash command --- cogs/kickban.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cogs/kickban.py b/cogs/kickban.py index 629a4719..49a4b32e 100644 --- a/cogs/kickban.py +++ b/cogs/kickban.py @@ -137,6 +137,9 @@ async def ban_member_slash(self, unban_time = timestamp + delta unban_time_string = format_dt(unban_time) + msg += f"\n\nThis ban expires in {unban_time_string}." + msg_send = await send_dm_message(member, msg) + try: await interaction.guild.ban(member, reason=reason, delete_message_days=delete_messages) except discord.errors.Forbidden: @@ -144,11 +147,11 @@ async def ban_member_slash(self, return await self.restrictions.add_restriction(member, Restriction.Ban, reason, end_date=unban_time) - msg += f"\n\nThis ban expires in {unban_time_string}." - msg_send = await send_dm_message(member, msg) await interaction.response.send_message(f"{member} is now b& until {unban_time_string}. 👍" + ("\nFailed to send DM message" if not msg_send else "")) else: unban_time = None + msg += "\n\nThis ban does not expire." + msg_send = await send_dm_message(member, msg) try: await interaction.guild.ban(member, reason=reason, delete_message_days=delete_messages) except discord.errors.Forbidden: @@ -156,8 +159,6 @@ async def ban_member_slash(self, return await self.restrictions.remove_restriction(member, Restriction.Ban) - msg += "\n\nThis ban does not expire." - msg_send = await send_dm_message(member, msg) await interaction.response.send_message(f"{member} is now b&. 👍" + ("\nFailed to send DM message" if not msg_send else "")) await self.bot.logs.post_action_log(interaction.user, member, 'ban', reason=reason, until=unban_time)