From e78beed6c7e094ef48aad5d18da01b2bbed4536c Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 19 Feb 2022 18:52:41 -0500 Subject: fix: a ton of shit --- src/commands/moderation/timeout.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/commands/moderation/timeout.ts') diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts index 32fcf76..b8fb78f 100644 --- a/src/commands/moderation/timeout.ts +++ b/src/commands/moderation/timeout.ts @@ -58,19 +58,16 @@ export default class TimeoutCommand extends BushCommand { message: BushMessage | BushSlashMessage, args: { user: ArgType<'user'>; reason_and_duration: ArgType<'contentWithDuration'> | string; 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 < 1) - return await message.util.reply(`${util.emojis.error} You must specify a duration for timeouts.`); - const member = await message.guild!.members.fetch(args.user.id).catch(() => null); + if (!duration) return await message.util.reply(`${util.emojis.error} You must specify a duration for timeouts.`); + 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, 'timeout', true, useForce); @@ -78,13 +75,10 @@ export default class TimeoutCommand extends BushCommand { return message.util.reply(canModerateResponse); } - const time = reason.duration; - const parsedReason = reason.contentWithoutTime ?? ''; - const responseCode = await member.bushTimeout({ - reason: parsedReason, + reason: content, moderator: message.member, - duration: time + duration: duration }); const responseMessage = (): string => { -- cgit