diff options
Diffstat (limited to 'src/commands/moderation/mute.ts')
-rw-r--r-- | src/commands/moderation/mute.ts | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index c97ceb7..e32ece2 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -64,18 +64,15 @@ export default class MuteCommand extends BushCommand { force?: ArgType<'boolean'>; } ) { - const reason = args.reason_and_duration - ? typeof args.reason_and_duration === 'string' - ? await util.arg.cast('contentWithDuration', message, args.reason_and_duration) - : args.reason_and_duration - : { duration: null, contentWithoutTime: '' }; + assert(message.inGuild()); + assert(message.member); + + const { duration, content } = await util.castDurationContent(args.reason_and_duration, message); - if (reason.duration === null) reason.duration = 0; - const member = await message.guild!.members.fetch(args.user.id).catch(() => null); + const member = await message.guild.members.fetch(args.user.id).catch(() => null); 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.`); - assert(message.member); const useForce = args.force && message.author.isOwner(); const canModerateResponse = await Moderation.permissionCheck(message.member, member, 'mute', true, useForce); @@ -83,18 +80,10 @@ export default class MuteCommand extends BushCommand { return message.util.reply(canModerateResponse); } - const time = reason - ? typeof reason === 'string' - ? ((await util.arg.cast('duration', message, reason)) as number) - : reason.duration - : undefined; - - const parsedReason = reason?.contentWithoutTime ?? ''; - const responseCode = await member.bushMute({ - reason: parsedReason, + reason: content, moderator: message.member, - duration: time ?? 0 + duration }); const responseMessage = (): string => { |