From 922dd7556e9938a08f8448632a5ee04519fb621d Mon Sep 17 00:00:00 2001 From: smyalygames Date: Fri, 17 Feb 2023 01:04:26 +0000 Subject: [PATCH] feat(arabot): remove temp ban if unban command is run --- src/commands/mod/ban/unban.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/commands/mod/ban/unban.ts b/src/commands/mod/ban/unban.ts index 03cfb8e..62bf738 100644 --- a/src/commands/mod/ban/unban.ts +++ b/src/commands/mod/ban/unban.ts @@ -29,6 +29,7 @@ import type { import { EmbedBuilder } from 'discord.js'; import IDs from '#utils/ids'; import { removeBan, checkBan, addBan } from '#utils/database/ban'; +import { checkTempBan, removeTempBan } from '#utils/database/tempBan'; import { addEmptyUser, addExistingUser, userExists } from '#utils/database/dbExistingUser'; export class UnbanCommand extends Command { @@ -142,7 +143,10 @@ export class UnbanCommand extends Command { } } - if (!await checkBan(userId)) { + let dbBan = await checkBan(userId); + const dbTempBan = await checkTempBan(userId); + + if (!dbBan && !dbTempBan) { let ban: GuildBan; try { ban = await guild.bans.fetch(userId); @@ -167,14 +171,19 @@ export class UnbanCommand extends Command { // Add missing ban await addBan(userId, modId, `(Mod who banned is not accurate) - ${reason}`); + dbBan = true; } // Unban the user await guild.members.unban(user) .catch(() => {}); - // Add unban to database - await removeBan(user.id, mod.user.id); + if (dbBan) { + // Add unban to database + await removeBan(user.id, mod.user.id); + } else if (dbTempBan) { + await removeTempBan(user.id, mod.user.id); + } info.message = `${user} has been unbanned.`; info.success = true;