diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-23 18:09:55 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-23 18:09:55 -0400 |
commit | 36ff682e742021918d134ff91a2bee3041b5a2b9 (patch) | |
tree | 979fb8a10eb7f210989ed3272754ab3f001641f5 /src/commands/moderation | |
parent | 44521f4560dc8b0bab055685437d8fa65a34377f (diff) | |
download | tanzanite-36ff682e742021918d134ff91a2bee3041b5a2b9.tar.gz tanzanite-36ff682e742021918d134ff91a2bee3041b5a2b9.tar.bz2 tanzanite-36ff682e742021918d134ff91a2bee3041b5a2b9.zip |
a ton of bug fixes
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/ban.ts | 38 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/purge.ts | 2 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 3 |
7 files changed, 23 insertions, 32 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 74b1b54..a267b78 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,6 +1,5 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, Moderation } from '@lib'; import { Snowflake, User } from 'discord.js'; -import { Moderation } from '../../lib/common/Moderation'; export default class BanCommand extends BushCommand { public constructor() { @@ -35,8 +34,7 @@ export default class BanCommand extends BushCommand { id: 'days', flag: '--days', match: 'option', - customType: util.arg.range('integer', 0, 7, true), - default: 0 + customType: util.arg.range('integer', 0, 7, true) }, { id: 'force', @@ -83,25 +81,21 @@ export default class BanCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - { - user: _user, - reason, - days, - force - }: { + args: { user: User | Snowflake; reason?: { duration: number | null; contentWithoutTime: string }; days?: number; force: boolean; } ): Promise<unknown> { - if (reason?.duration === null) reason.duration = 0; + if (typeof args.reason === 'object') args.reason.duration ??= 0; + args.days ??= 0; if (!message.guild) return message.util.reply(`${util.emojis.error} This command cannot be used in dms.`); - const member = message.guild!.members.cache.get((_user as User)?.id); - const user = member?.user ?? (await util.resolveNonCachedUser(_user)); + const member = message.guild!.members.cache.get((args.user as User)?.id ?? args.user); + const user = member?.user ?? (await util.resolveNonCachedUser((args.user as User)?.id ?? args.user)); if (!user) return message.util.reply(`${util.emojis.error} Invalid user.`); - const useForce = force && message.author.isOwner(); + const useForce = args.force && message.author.isOwner(); if (!message.member) throw new Error(`message.member is null`); const canModerateResponse = member ? await Moderation.permissionCheck(message.member, member, 'ban', true, useForce) : true; @@ -110,31 +104,33 @@ export default class BanCommand extends BushCommand { return await message.util.reply(canModerateResponse); } - if (message.util.parsed?.alias === 'dban' && !days) days = 1; + if (message.util.parsed?.alias === 'dban' && !args.days) args.days = 1; + + if (!Number.isInteger(args.days) || args.days! < 0 || args.days! > 7) { + client.console.debug(args.days); - if (!Number.isInteger(days) || days! < 0 || days! > 7) { return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`); } let time: number; - if (reason) { - time = typeof reason === 'string' ? await util.arg.cast('duration', message, reason) : reason.duration; + if (args.reason) { + time = typeof args.reason === 'string' ? await util.arg.cast('duration', message, args.reason) : args.reason.duration; } - const parsedReason = reason?.contentWithoutTime ?? null; + const parsedReason = args.reason?.contentWithoutTime ?? null; const responseCode = member ? await member.bushBan({ reason: parsedReason, moderator: message.member, duration: time! ?? 0, - deleteDays: days ?? 0 + deleteDays: args.days }) : await message.guild.bushBan({ user, reason: parsedReason, moderator: message.member, duration: time! ?? 0, - deleteDays: days ?? 0 + deleteDays: args.days }); const responseMessage = () => { diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 3238217..d4edb07 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/Moderation'; +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser, Moderation } from '@lib'; export default class KickCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index 4abaa6f..6840f4e 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -1,6 +1,5 @@ -import { BushCommand, BushMessage, BushSlashMessage, BushUser, ModLog } from '@lib'; +import { BushCommand, BushMessage, BushSlashMessage, BushUser, ButtonPaginator, ModLog } from '@lib'; import { MessageEmbed, User } from 'discord.js'; -import { ButtonPaginator } from '../../lib/common/ButtonPaginator'; export default class ModlogCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 00631ba..897e95a 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/Moderation'; +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser, Moderation } from '@lib'; export default class MuteCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index a77e46a..65555a1 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,5 +1,5 @@ +import { BushCommand, BushMessage } from '@lib'; import { Collection, Snowflake } from 'discord.js'; -import { BushCommand, BushMessage } from '../../lib'; export default class PurgeCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index f9335c4..3b4f5bd 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/Moderation'; +import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser, Moderation } from '@lib'; export default class UnmuteCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index c67466b..c510929 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,5 +1,4 @@ -import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/Moderation'; +import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser, Moderation } from '@lib'; export default class WarnCommand extends BushCommand { public constructor() { |