aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/common/AutoMod.ts18
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts2
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts5
3 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index 50f5d3e..7a30820 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -1,4 +1,4 @@
-import { Moderation, type BushButtonInteraction, type BushMessage } from '#lib';
+import { banResponse, Moderation, type BushButtonInteraction, type BushMessage } from '#lib';
import { GuildMember, MessageActionRow, MessageButton, MessageEmbed, type TextChannel } from 'discord.js';
/**
@@ -308,18 +308,20 @@ export class AutoMod {
evidence: (interaction.message as BushMessage).url ?? undefined
});
- if (result === 'success')
+ const victimUserFormatted = (await util.resolveNonCachedUser(userId))?.tag ?? userId;
+ if (result === banResponse.SUCCESS)
return interaction.reply({
- content: `${util.emojis.success} Successfully banned **${
- interaction.guild?.members.cache.get(userId)?.user.tag ?? userId
- }**.`,
+ content: `${util.emojis.success} Successfully banned **${victimUserFormatted}**.`,
+ ephemeral: true
+ });
+ else if (result === banResponse.DM_ERROR)
+ return interaction.reply({
+ content: `${util.emojis.warn} Banned ${victimUserFormatted} however I could not send them a dm.`,
ephemeral: true
});
else
return interaction.reply({
- content: `${util.emojis.error} Could not ban **${
- interaction.guild?.members.cache.get(userId)?.user.tag ?? userId
- }**: \`${result}\` .`,
+ content: `${util.emojis.error} Could not ban **${victimUserFormatted}**: \`${result}\` .`,
ephemeral: true
});
}
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
index 0011ce6..33ee3fc 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -163,6 +163,8 @@ export class BushGuild extends Guild {
const user = (await util.resolveNonCachedUser(options.user))!;
const moderator = client.users.resolve(options.moderator ?? client.user!)!;
+ if ((await this.bans.fetch()).has(user.id)) return banResponse.ALREADY_BANNED;
+
const ret = await (async () => {
// dm user
dmSuccessEvent = await Moderation.punishDM({
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts
index 6a95ebf..54fb3f0 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/BushGuildMember.ts
@@ -465,7 +465,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for banning the user.
* @emits {@link BushClientEvents.bushBan}
*/
- public async bushBan(options: BushBanOptions): Promise<BanResponse> {
+ public async bushBan(options: BushBanOptions): Promise<Exclude<BanResponse, typeof banResponse['ALREADY_BANNED']>> {
// checks
if (!this.guild.me!.permissions.has('BAN_MEMBERS') || !this.bannable) return banResponse.MISSING_PERMISSIONS;
@@ -1025,7 +1025,8 @@ export const kickResponse = Object.freeze({
export const banResponse = Object.freeze({
...dmResponse,
...permissionsResponse,
- ...punishmentEntryAdd
+ ...punishmentEntryAdd,
+ ALREADY_BANNED: 'already banned'
} as const);
export const blockResponse = Object.freeze({