From 0ccfcbe3bec20a406434b917a0d6fbef84eb35e7 Mon Sep 17 00:00:00 2001 From: MrSerge01 <86667481+MrSerge01@users.noreply.github.com> Date: Sun, 3 Nov 2024 21:57:14 +0500 Subject: [PATCH] quick fix --- src/commands/moderation/Ban.ts | 7 +++++++ src/commands/moderation/Kick.ts | 8 ++++++++ src/commands/moderation/Unban.ts | 4 +--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/commands/moderation/Ban.ts b/src/commands/moderation/Ban.ts index 5d2f9b3..0dbc4de 100644 --- a/src/commands/moderation/Ban.ts +++ b/src/commands/moderation/Ban.ts @@ -38,6 +38,13 @@ export default class Ban { ) return; + if ((await guild.bans.fetch()).get(user.id)) + return await errorEmbed( + interaction, + `You can't ban ${user.displayName}.`, + "This user is already banned." + ); + let expiresAt: number | undefined; if (duration) { const durationMs = ms(duration); diff --git a/src/commands/moderation/Kick.ts b/src/commands/moderation/Kick.ts index e302404..c67bae8 100644 --- a/src/commands/moderation/Kick.ts +++ b/src/commands/moderation/Kick.ts @@ -3,6 +3,7 @@ import { SlashCommandSubcommandBuilder, type ChatInputCommandInteraction } from "discord.js"; +import { errorEmbed } from "../../utils/embeds/errorEmbed"; import { errorCheck, modEmbed } from "../../utils/embeds/modEmbed"; export default class Kick { @@ -31,6 +32,13 @@ export default class Kick { ) return; + if (!interaction.guild?.members.cache.get(user.id)) + return await errorEmbed( + interaction, + `You can't kick ${user.displayName}.`, + "This user is not in the server." + ); + const reason = interaction.options.getString("reason"); await interaction.guild?.members.cache .get(user.id) diff --git a/src/commands/moderation/Unban.ts b/src/commands/moderation/Unban.ts index 922d1f3..a8d5d8e 100644 --- a/src/commands/moderation/Unban.ts +++ b/src/commands/moderation/Unban.ts @@ -27,9 +27,7 @@ export default class Unban { const id = interaction.options.getString("id")!; const reason = interaction.options.getString("reason")!; const guild = interaction.guild!; - const target = (await guild.bans.fetch()) - .map(ban => ban.user) - .filter(user => user.id == id)[0]!; + const target = (await guild.bans.fetch()).get(id)?.user!; if ( await errorCheck(