Skip to content

Commit

Permalink
kickban.py: Fix ban slash command
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenChen committed Oct 10, 2024
1 parent 4694865 commit 6997f23
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cogs/kickban.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,28 @@ 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:
await interaction.response.send_message("Failed to ban member.")
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:
await interaction.response.send_message("Failed to ban member.")
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)

Expand Down

0 comments on commit 6997f23

Please sign in to comment.