diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-27 13:12:49 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-27 13:12:49 -0500 |
commit | e05f25f4b98cac3c2409cee9a664ab5ea6251467 (patch) | |
tree | f8e3dc4fde8f6deaa543b910acb9a725abbac999 /src/commands/utilities | |
parent | 84f246ebb5ddee984012d3043dcc67ffae806856 (diff) | |
download | tanzanite-e05f25f4b98cac3c2409cee9a664ab5ea6251467.tar.gz tanzanite-e05f25f4b98cac3c2409cee9a664ab5ea6251467.tar.bz2 tanzanite-e05f25f4b98cac3c2409cee9a664ab5ea6251467.zip |
better typings and some other stuff
Diffstat (limited to 'src/commands/utilities')
-rw-r--r-- | src/commands/utilities/activity.ts | 6 | ||||
-rw-r--r-- | src/commands/utilities/steal.ts | 6 | ||||
-rw-r--r-- | src/commands/utilities/uuid.ts | 5 | ||||
-rw-r--r-- | src/commands/utilities/viewRaw.ts | 23 | ||||
-rw-r--r-- | src/commands/utilities/whoHasRole.ts | 6 |
5 files changed, 31 insertions, 15 deletions
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts index 2ab56cc..fe21aec 100644 --- a/src/commands/utilities/activity.ts +++ b/src/commands/utilities/activity.ts @@ -1,5 +1,5 @@ -import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { DiscordAPIError, Message, VoiceChannel } from 'discord.js'; +import { ArgType, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; +import { DiscordAPIError, Message } from 'discord.js'; const activityMap = { 'Poker Night': { @@ -131,7 +131,7 @@ export default class YouTubeCommand extends BushCommand { }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { channel: VoiceChannel; activity: string }) { + public override async exec(message: BushMessage | BushSlashMessage, args: { channel: ArgType<'channel'>; activity: string }) { const channel = typeof args.channel === 'string' ? message.guild?.channels.cache.get(args.channel) : args.channel; if (!channel || channel.type !== 'GUILD_VOICE') return await message.util.reply(`${util.emojis.error} Choose a valid voice channel`); diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 6a15d71..480201a 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,7 +1,7 @@ -import { BushCommand, BushSlashMessage, type BushMessage } from '#lib'; +import { ArgType, BushCommand, BushSlashMessage, type BushMessage } from '#lib'; import { ArgumentOptions, ArgumentType, ArgumentTypeCaster, Flag } from 'discord-akairo'; -import { type Snowflake } from 'discord.js'; import _ from 'lodash'; +import { URL } from 'url'; export default class StealCommand extends BushCommand { public constructor() { @@ -72,7 +72,7 @@ export default class StealCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args?: { emoji?: { name: string; id: Snowflake } | Snowflake | URL | string; name: string } + args?: { emoji?: ArgType<'discordEmoji'> | ArgType<'snowflake'> | ArgType<'url'> | string; name: string } ) { if (!args || !args.emoji) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts index e0f6b1c..6195edd 100644 --- a/src/commands/utilities/uuid.ts +++ b/src/commands/utilities/uuid.ts @@ -34,7 +34,10 @@ export default class UuidCommand extends BushCommand { }); } - public override async exec(message: BushMessage, { ign, dashed }: { ign: { match: any[]; matches: any[] }; dashed: boolean }) { + public override async exec( + message: BushMessage, + { ign, dashed }: { ign: { match: RegExpMatchArray; matches: any[] }; dashed: boolean } + ) { if (!ign) return await message.util.reply(`${util.emojis.error} Please enter a valid ign.`); const readableIGN = ign.match[0]; try { diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts index 0809a39..eeec4d9 100644 --- a/src/commands/utilities/viewRaw.ts +++ b/src/commands/utilities/viewRaw.ts @@ -1,5 +1,13 @@ -import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Message, MessageEmbed, type DMChannel, type NewsChannel, type Snowflake, type TextChannel } from 'discord.js'; +import { + ArgType, + BushCommand, + BushNewsChannel, + BushTextChannel, + OptionalArgType, + type BushMessage, + type BushSlashMessage +} from '#lib'; +import { Message, MessageEmbed, type Snowflake } from 'discord.js'; export default class ViewRawCommand extends BushCommand { public constructor() { @@ -22,7 +30,7 @@ export default class ViewRawCommand extends BushCommand { { id: 'channel', description: 'The channel that the message is in.', - type: 'channel', + type: util.arg.union('textChannel', 'newsChannel'), prompt: 'What channel is the message in?', retry: '{error} Choose a valid channel.', optional: true, @@ -57,9 +65,14 @@ export default class ViewRawCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { message: BushMessage | Snowflake; channel: TextChannel | NewsChannel | DMChannel; json?: boolean; js: boolean } + args: { + message: ArgType<'guildMessage'> | ArgType<'messageLink'>; + channel: OptionalArgType<'textChannel'> | OptionalArgType<'newsChannel'>; + json: boolean; + js: boolean; + } ) { - if (!args.channel) args.channel = (message.channel as TextChannel | NewsChannel | DMChannel)!; + if (!args.channel) args.channel = (message.channel as BushTextChannel | BushNewsChannel)!; const newMessage = args.message instanceof Message ? args.message diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts index 45cf77f..ffb7ce1 100644 --- a/src/commands/utilities/whoHasRole.ts +++ b/src/commands/utilities/whoHasRole.ts @@ -1,5 +1,5 @@ -import { BushCommand, ButtonPaginator, type BushMessage, type BushSlashMessage } from '#lib'; -import { Util, type CommandInteraction, type Role } from 'discord.js'; +import { ArgType, BushCommand, ButtonPaginator, type BushMessage, type BushSlashMessage } from '#lib'; +import { Util, type CommandInteraction } from 'discord.js'; export default class WhoHasRoleCommand extends BushCommand { public constructor() { @@ -27,7 +27,7 @@ export default class WhoHasRoleCommand extends BushCommand { typing: true }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { role: Role }) { + public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'> }) { if (message.util.isSlash) await (message.interaction as CommandInteraction).deferReply(); const roleMembers = args.role.members.map((member) => `${member.user} (${Util.escapeMarkdown(member.user.tag)})`); |