diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-19 18:52:41 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-19 18:52:41 -0500 |
commit | e78beed6c7e094ef48aad5d18da01b2bbed4536c (patch) | |
tree | 32676793af5f7bdc39d438ff284fa5b959274e96 /src/commands/moderation/block.ts | |
parent | a3103b629250de3fb97a40a4f9ff7e7ba28f4d16 (diff) | |
download | tanzanite-e78beed6c7e094ef48aad5d18da01b2bbed4536c.tar.gz tanzanite-e78beed6c7e094ef48aad5d18da01b2bbed4536c.tar.bz2 tanzanite-e78beed6c7e094ef48aad5d18da01b2bbed4536c.zip |
fix: a ton of shit
Diffstat (limited to 'src/commands/moderation/block.ts')
-rw-r--r-- | src/commands/moderation/block.ts | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts index 20c6e86..e6f7849 100644 --- a/src/commands/moderation/block.ts +++ b/src/commands/moderation/block.ts @@ -2,8 +2,6 @@ import { AllowedMentions, blockResponse, BushCommand, - BushTextChannel, - BushThreadChannel, Moderation, type ArgType, type BushMessage, @@ -67,21 +65,17 @@ export default class BlockCommand extends BushCommand { } ) { assert(message.inGuild()); - if (!(message.channel instanceof BushTextChannel || message.channel instanceof BushThreadChannel)) - return message.util.send(`${util.emojis.error} This command can only be used in text and thread channels.`); + assert(message.member); + + if (!message.channel.isTextBased()) + return message.util.send(`${util.emojis.error} This command can only be used in text based channels.`); - 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: '' }; + 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, 'block', true, useForce); @@ -89,18 +83,10 @@ export default class BlockCommand 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.bushBlock({ - reason: parsedReason, + reason: content, moderator: message.member, - duration: time ?? 0, + duration: duration, channel: message.channel }); |