diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/dev/__template.ts | 4 | ||||
-rw-r--r-- | src/commands/moderation/lockdown.ts | 2 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 19 | ||||
-rw-r--r-- | src/commands/moderation/role.ts | 2 | ||||
-rw-r--r-- | src/commands/moderation/unlockdown.ts | 2 | ||||
-rw-r--r-- | src/lib/common/util/Moderation.ts | 16 | ||||
-rw-r--r-- | src/lib/utils/BushConstants.ts | 2 |
7 files changed, 33 insertions, 14 deletions
diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index 11d9649..6adba08 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -11,16 +11,16 @@ export default class TemplateCommand extends BushCommand { args: [ { id: 'required_argument', - type: 'string', description: 'This is the first argument.', + type: 'string', prompt: 'What would you like to set your first argument to be?', retry: '{error} Pick a valid argument.', slashType: 'STRING' }, { id: 'optional_argument', - type: 'string', description: 'This is the second argument.', + type: 'string', prompt: 'What would you like to set your second argument to be?', retry: '{error} Pick a valid argument.', optional: true, diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index 7a0b9d8..b9febbd 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -16,7 +16,7 @@ import { Collection } from 'discord.js'; export default class LockdownCommand extends BushCommand { public constructor() { super('lockdown', { - aliases: ['lockdown'], + aliases: ['lockdown', 'lock'], category: 'moderation', description: 'Allows you to lockdown a channel or all configured channels.', usage: ['lockdown [channel] [reason] [--all]'], diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index ae37fed..eeffc6c 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,4 +1,13 @@ -import { AllowedMentions, BushCommand, Moderation, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; +import { + AllowedMentions, + BushCommand, + Moderation, + type ArgType, + type BushMessage, + type BushSlashMessage, + type OptionalArgType +} from '#lib'; +import assert from 'assert'; export default class MuteCommand extends BushCommand { public constructor() { @@ -19,7 +28,7 @@ export default class MuteCommand extends BushCommand { }, { id: 'reason', - description: 'The reason for the mute.', + description: 'The reason and duration of the mute.', type: 'contentWithDuration', match: 'rest', prompt: 'Why should this user be muted and for how long?', @@ -47,9 +56,9 @@ export default class MuteCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { user: ArgType<'user'>; reason?: ArgType<'contentWithDuration'> | string; force: boolean } + args: { user: ArgType<'user'>; reason: OptionalArgType<'contentWithDuration'> | string; force?: ArgType<'boolean'> } ) { - const reason: { duration: number | null; contentWithoutTime: string | null } = args.reason + const reason = args.reason ? typeof args.reason === 'string' ? await util.arg.cast('contentWithDuration', message, args.reason) : args.reason @@ -60,7 +69,7 @@ export default class MuteCommand extends BushCommand { if (!member) return await message.util.reply(`${util.emojis.error} The user you selected is not in the server or is not a valid user.`); - if (!message.member) throw new Error(`message.member is null`); + assert(message.member); const useForce = args.force && message.author.isOwner(); const canModerateResponse = await Moderation.permissionCheck(message.member, member, 'mute', true, useForce); diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 2375bff..9fd34b5 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -130,7 +130,7 @@ export default class RoleCommand extends BushCommand { const a = mappings.roleMap[i]; if (a.id === args.role.id) mappedRole = a; } - if (!mappedRole! || !Reflect.has(mappings.roleWhitelist, mappedRole.name)) { + if (!mappedRole! || !(mappedRole.name in mappings.roleWhitelist)) { return await message.util.reply({ content: `${util.emojis.error} <@&${args.role.id}> is not whitelisted, and you do not have manage roles permission.`, allowedMentions: AllowedMentions.none() diff --git a/src/commands/moderation/unlockdown.ts b/src/commands/moderation/unlockdown.ts index 87b27eb..24af305 100644 --- a/src/commands/moderation/unlockdown.ts +++ b/src/commands/moderation/unlockdown.ts @@ -4,7 +4,7 @@ import LockdownCommand from './lockdown.js'; export default class UnlockdownCommand extends BushCommand { public constructor() { super('unlockdown', { - aliases: ['unlockdown'], + aliases: ['unlockdown', 'unlock'], category: 'moderation', description: 'Allows you to unlockdown a channel or all configured channels.', usage: ['unlockdown [channel] [reason] [--all]'], diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts index 3cabb77..c06ad25 100644 --- a/src/lib/common/util/Moderation.ts +++ b/src/lib/common/util/Moderation.ts @@ -26,7 +26,17 @@ export class Moderation { public static async permissionCheck( moderator: BushGuildMember, victim: BushGuildMember, - type: 'mute' | 'unmute' | 'warn' | 'kick' | 'ban' | 'unban' | 'add a punishment role to' | 'remove a punishment role from', + type: + | 'mute' + | 'unmute' + | 'warn' + | 'kick' + | 'ban' + | 'unban' + | 'add a punishment role to' + | 'remove a punishment role from' + | 'block' + | 'unblock', checkModerator = true, force = false ): Promise<true | string> { @@ -262,7 +272,7 @@ export interface CreatePunishmentEntryOptions { modlog: string; /** - * The role id if the punishment is a role punishment. + * Extra information for the punishment. The role for role punishments and the channel for blocks. */ extraInfo?: Snowflake; } @@ -287,7 +297,7 @@ export interface RemovePunishmentEntryOptions { guild: BushGuildResolvable; /** - * The role id if the punishment is a role punishment. + * Extra information for the punishment. The role for role punishments and the channel for blocks. */ extraInfo?: Snowflake; } diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 3327e8f..4f5fb87 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -169,7 +169,7 @@ export class BushConstants { USE_EXTERNAL_STICKERS: { name: 'Use External Stickers', important: false }, SEND_MESSAGES_IN_THREADS: { name: 'Send Messages In Threads', important: false }, START_EMBEDDED_ACTIVITIES: { name: 'Start Activities', important: false }, - MODERATE_MEMBERS: { name: 'Moderate Members', important: true }, + MODERATE_MEMBERS: { name: 'Timeout Members', important: true }, MANAGE_EVENTS: { name: 'Manage Events', important: true } }, |