diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts index 7c68638..b55474a 100644 --- a/src/commands/mod/unban.ts +++ b/src/commands/mod/unban.ts @@ -20,7 +20,7 @@ import { Args, Command, RegisterBehavior } from '@sapphire/framework'; import type { User, Message, TextChannel } from 'discord.js'; import IDs from '../../utils/ids'; -import { removeBan } from '../../utils/database/ban'; +import { removeBan, checkActive } from '../../utils/database/ban'; class UnbanCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -64,27 +64,26 @@ class UnbanCommand extends Command { return; } - // Unban the user - try { - await guild.members.unban(user); - } catch { + if (!await checkActive(user.id)) { await interaction.reply({ content: `${user} is not banned.`, - ephemeral: true, - fetchReply: true, }); return; } + // Unban the user + await guild.members.unban(user) + .catch(() => {}); + + // Add unban to database + await removeBan(user.id, mod.user.id); + await interaction.reply({ content: `${user} has been unbanned.`, ephemeral: true, fetchReply: true, }); - // Add unban to database - await removeBan(user.id, mod.user.id); - // Log the ban let modRestrict = guild.channels.cache.get(IDs.channels.restricted.moderators) as TextChannel | undefined; @@ -127,10 +126,7 @@ class UnbanCommand extends Command { return; } - // Unban the user - try { - await guild.members.unban(user); - } catch { + if (!await checkActive(user.id)) { await message.react('❌'); await message.reply({ content: `${user} is not banned.`, @@ -138,11 +134,15 @@ class UnbanCommand extends Command { return; } - await message.react('✅'); + // Unban the user + await guild.members.unban(user) + .catch(() => {}); // Add unban to database await removeBan(user.id, mod.id); + await message.react('✅'); + await message.reply({ content: `${user} has been unbanned.`, });