aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-15 18:20:34 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-15 18:20:34 -0500
commit85c9e01741c1c8e5c7a755605f2a39d26a3a4be8 (patch)
tree1ed5c3810eb24ea9175f6caffc367cdc8597a6a1
parentdc273dd2801ba54ecb74fb1be75bc64eff5d551c (diff)
downloadtanzanite-85c9e01741c1c8e5c7a755605f2a39d26a3a4be8.tar.gz
tanzanite-85c9e01741c1c8e5c7a755605f2a39d26a3a4be8.tar.bz2
tanzanite-85c9e01741c1c8e5c7a755605f2a39d26a3a4be8.zip
don't ban users that are already banned
-rw-r--r--src/commands/moderation/ban.ts2
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts2
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts5
3 files changed, 7 insertions, 2 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 7f0b91f..aeb03f0 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -127,6 +127,8 @@ export default class BanCommand extends BushCommand {
const responseMessage = (): string => {
const victim = util.format.input(user.tag);
switch (responseCode) {
+ case banResponse.ALREADY_BANNED:
+ return `${util.emojis.error} ${victim} is already banned.`;
case banResponse.MISSING_PERMISSIONS:
return `${util.emojis.error} Could not ban ${victim} because I am missing the **Ban Members** permission.`;
case banResponse.ACTION_ERROR:
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({