From 920828c3e65638312faa250d510df10669db5f20 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:25:44 -0800 Subject: [PATCH] Cancel punishment if user is already banned --- src/client.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 5a3c637..9be7b09 100644 --- a/src/client.ts +++ b/src/client.ts @@ -290,7 +290,12 @@ class punishments extends Database { } if (['ban', 'softban'].includes(type)) { - punResult = await guild.bans.create(User.id, {reason: `${reason} | Case #${punData.id}`}).catch((err: Error) => err.message); + const banned = await guild.bans.fetch(User.id).catch(() => undefined); + if (!banned) { + punResult = await guild.bans.create(User.id, {reason: `${reason} | Case #${punData.id}`}).catch((err: Error) => err.message); + } else { + punResult = 'User is already banned.'; + } } else if (type == 'kick') { punResult = await GuildMember?.kick(`${reason} | Case #${punData.id}`).catch((err: Error) => err.message); } else if (type == 'mute') {