diff options
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/ban.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 4 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 3 |
5 files changed, 12 insertions, 8 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 3a86244..7f1a67c 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -93,7 +93,8 @@ export default class BanCommand extends BushCommand { 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.id) as BushGuildMember; const useForce = force && message.author.isOwner(); - const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'ban', true, useForce); + if (!message.member) throw new Error(`message.member is null`); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'ban', true, useForce); if (canModerateResponse !== true) { return message.util.reply(canModerateResponse); diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 8864320..2315712 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -62,9 +62,9 @@ export default class KickCommand extends BushCommand { const member = message.guild!.members.cache.get(user.id) as BushGuildMember; if (!member) return await message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`); - + if (!message.member) throw new Error(`message.member is null`); const useForce = force && message.author.isOwner(); - const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'kick', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'kick', true, useForce); if (canModerateResponse !== true) { return message.util.reply(canModerateResponse); diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index e6c9065..7b8689a 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib'; +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; import { Argument } from 'discord-akairo'; export default class MuteCommand extends BushCommand { @@ -61,11 +61,12 @@ export default class MuteCommand extends BushCommand { message: BushMessage | BushSlashMessage, { user, reason, force }: { user: BushUser; reason?: { duration: number; contentWithoutTime: string }; force: boolean } ): Promise<unknown> { - const member = message.guild!.members.cache.get(user.id) as BushGuildMember; + const member = message.guild!.members.cache.get(user.id); if (!member) return await message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`); + if (!message.member) throw new Error(`message.member is null`); const useForce = force && message.author.isOwner(); - const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'mute', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'mute', true, useForce); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 7e93d31..acbda3e 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -57,7 +57,8 @@ export default class UnmuteCommand extends BushCommand { ): Promise<unknown> { const error = util.emojis.error; const member = message.guild!.members.cache.get(user.id) as BushGuildMember; - const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'unmute'); + if (!message.member) throw new Error(`message.member is null`); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'unmute'); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 33ac2a3..a9469cf 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -61,7 +61,8 @@ export default class WarnCommand extends BushCommand { ): Promise<unknown> { const member = message.guild!.members.cache.get(user.id) as BushGuildMember; const useForce = force && message.author.isOwner(); - const canModerateResponse = util.moderationPermissionCheck(message.member!, member, 'warn', true, useForce); + if (!message.member) throw new Error(`message.member is null`); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'warn', true, useForce); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { |