diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-11-28 09:27:41 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-11-28 09:27:41 -0500 |
commit | 453683b57b8ff013ff25e2aaa4aa1d2e047edcb7 (patch) | |
tree | 8b98d2f30dbb6a8448602446cfacf9091667cc33 /src/commands/info | |
parent | de4c3dcaf172804d34ae708be1ed3e75af42f4d5 (diff) | |
download | tanzanite-453683b57b8ff013ff25e2aaa4aa1d2e047edcb7.tar.gz tanzanite-453683b57b8ff013ff25e2aaa4aa1d2e047edcb7.tar.bz2 tanzanite-453683b57b8ff013ff25e2aaa4aa1d2e047edcb7.zip |
a few small changes
Diffstat (limited to 'src/commands/info')
-rw-r--r-- | src/commands/info/avatar.ts | 29 | ||||
-rw-r--r-- | src/commands/info/botInfo.ts | 8 | ||||
-rw-r--r-- | src/commands/info/color.ts | 38 | ||||
-rw-r--r-- | src/commands/info/guildInfo.ts | 63 | ||||
-rw-r--r-- | src/commands/info/help.ts | 49 | ||||
-rw-r--r-- | src/commands/info/icon.ts | 8 | ||||
-rw-r--r-- | src/commands/info/links.ts | 8 | ||||
-rw-r--r-- | src/commands/info/ping.ts | 8 | ||||
-rw-r--r-- | src/commands/info/pronouns.ts | 26 | ||||
-rw-r--r-- | src/commands/info/snowflake.ts | 54 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 29 |
11 files changed, 132 insertions, 188 deletions
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index e8b213f..87ea0cc 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -6,33 +6,24 @@ export default class AvatarCommand extends BushCommand { super('avatar', { aliases: ['avatar', 'av'], category: 'info', - description: { - content: "A command to get a user's avatar", - usage: ['avatar [user]'], - examples: ['avatar', 'av IRONM00N'] - }, + description: "A command to get a user's avatar", + usage: ['avatar [user]'], + examples: ['avatar', 'av IRONM00N'], args: [ { id: 'user', + description: 'The user you would like to find the avatar of.', customType: util.arg.union('member', 'globalUser'), - prompt: { - start: 'Who would you like to see the avatar of?', - retry: '{error} Choose a valid user.', - optional: true - } + readableType: 'member|user', + prompt: 'Who would you like to see the avatar of?', + retry: '{error} Choose a valid user.', + optional: true, + slashType: 'USER' } ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [], - slash: true, - slashOptions: [ - { - name: 'user', - description: 'The user you would like to find the avatar of.', - type: 'USER', - required: false - } - ] + slash: true }); } diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 833ed96..56885c5 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -8,11 +8,9 @@ export default class BotInfoCommand extends BushCommand { super('botInfo', { aliases: ['bot-info', 'stats'], category: 'info', - description: { - content: 'Shows information about the bot', - usage: ['bot-info'], - examples: ['bot-info'] - }, + description: 'Shows information about the bot', + usage: ['bot-info'], + examples: ['bot-info'], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index 8fed7da..cb612b5 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -14,20 +14,19 @@ export default class ColorCommand extends BushCommand { super('color', { aliases: ['color'], category: 'info', - description: { - content: 'Find the color of a hex code, user, or role.', - usage: ['color <color|role|user>'], - examples: ['color #0000FF'] - }, + description: 'Find the color of a hex code, user, or role.', + usage: ['color <color|role|user>'], + examples: ['color #0000FF'], args: [ { id: 'color', + description: 'The color string, role, or member to find the color of.', customType: Argument.union(isValidTinyColor, 'role', 'member'), + readableType: 'color|role|member', match: 'restContent', - prompt: { - start: 'What color code, role, or user would you like to find the color of?', - retry: '{error} Choose a valid color, role, or member.' - } + prompt: 'What color code, role, or user would you like to find the color of?', + retry: '{error} Choose a valid color, role, or member.', + slashType: 'STRING' } ], channel: 'guild', @@ -41,16 +40,23 @@ export default class ColorCommand extends BushCommand { } public override async exec(message: BushMessage | BushSlashMessage, args: { color: string | BushRole | BushGuildMember }) { + const _color = message.util.isSlashMessage(message) + ? ((await util.arg.cast(Argument.union(isValidTinyColor, 'role', 'member'), message, args.color as string)) as + | string + | BushRole + | BushGuildMember) + : args.color; + const color = - typeof args.color === 'string' - ? tinycolor(args.color) - : args.color instanceof Role - ? tinycolor(args.color.hexColor) - : tinycolor(args.color.displayHexColor); + typeof _color === 'string' + ? tinycolor(_color) + : _color instanceof Role + ? tinycolor(_color.hexColor) + : tinycolor(_color.displayHexColor); - if (args.color instanceof Role && args.color.hexColor === '#000000') { + if (_color instanceof Role && _color.hexColor === '#000000') { return await message.util.reply({ - content: `${util.emojis.error} <@&${args.color.id}> does not have a color.`, + content: `${util.emojis.error} <@&${_color.id}> does not have a color.`, allowedMentions: AllowedMentions.none() }); } diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 47a8281..a38a446 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -14,31 +14,22 @@ export default class GuildInfoCommand extends BushCommand { super('guildInfo', { aliases: ['guild-info', 'serverinfo', 'guild', 'server', 'g'], category: 'info', - description: { - content: 'Get info about a server.', - usage: ['guild-info [guild]'], - examples: ['guild-info 516977525906341928'] - }, + description: 'Get info about a server.', + usage: ['guild-info [guild]'], + examples: ['guild-info 516977525906341928'], args: [ { id: 'guild', + description: 'The guild to find information about.', customType: util.arg.union('guild', 'snowflake'), - prompt: { - start: 'What server would you like to find information about?', - retry: '{error} Choose a valid server to find information about.', - optional: true - } + readableType: 'guild|snowflake', + prompt: 'What server would you like to find information about?', + retry: '{error} Choose a valid server to find information about.', + optional: true, + slashType: 'STRING' } ], slash: true, - slashOptions: [ - { - name: 'guild', - description: 'The id of the guild you would like to find information about.', - type: 'STRING', - required: false - } - ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] }); @@ -67,23 +58,15 @@ export default class GuildInfoCommand extends BushCommand { const guildStats: string[] = []; const guildSecurity: string[] = []; const verifiedGuilds = Object.values(client.consts.mappings.guilds); - if (verifiedGuilds.includes(guild.id)) emojis.push(otherEmojis.BUSH_VERIFIED); + if (verifiedGuilds.includes(guild.id as typeof verifiedGuilds[number])) emojis.push(otherEmojis.BUSH_VERIFIED); if (!isPreview && guild instanceof Guild) { if (guild.premiumTier !== 'NONE') emojis.push(otherEmojis[`BOOST_${guild.premiumTier}`]); await guild.fetch(); const channels = guild.channels.cache; - type ChannelType = - | 'GUILD_TEXT' - | 'GUILD_NEWS' - | 'GUILD_VOICE' - | 'GUILD_STAGE_VOICE' - | 'GUILD_STORE' - | 'GUILD_CATEGORY' - | 'THREAD'; const channelTypes = ( - ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as ChannelType[] + ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as const ).map((type) => `${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`); const guildRegions = [ @@ -113,18 +96,18 @@ export default class GuildInfoCommand extends BushCommand { if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, format: 'png' })})`); if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, format: 'png' })})`); - enum EmojiTierMap { - TIER_3 = 500, - TIER_2 = 300, - TIER_1 = 100, - NONE = 50 - } - enum StickerTierMap { - TIER_3 = 60, - TIER_2 = 30, - TIER_1 = 15, - NONE = 0 - } + const EmojiTierMap = { + TIER_3: 500, + TIER_2: 300, + TIER_1: 100, + NONE: 50 + } as const; + const StickerTierMap = { + TIER_3: 60, + TIER_2: 30, + TIER_1: 15, + NONE: 0 + } as const; guildStats.push( `**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`, diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 3bf8f5e..3b7883f 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -7,33 +7,32 @@ export default class HelpCommand extends BushCommand { super('help', { aliases: ['help'], category: 'info', - description: { - content: 'Displays a list of commands, or detailed information for a specific command.', - usage: ['help [command]'], - examples: ['help prefix'] - }, + description: 'Displays a list of commands, or detailed information for a specific command.', + usage: ['help [command]'], + examples: ['help prefix'], args: [ { id: 'command', + description: 'The command to show info about.', type: 'commandAlias', match: 'content', - prompt: { - start: 'What command do you need help with?', - retry: '{error} Choose a valid command to find help for.', - optional: true - } + prompt: 'What command do you need help with?', + retry: '{error} Choose a valid command to find help for.', + slashType: 'STRING', + optional: true }, - { id: 'showHidden', match: 'flag', flag: '--hidden' } - ], - slash: true, - slashOptions: [ { - name: 'command', - description: 'What command do you need help with?', - type: 'STRING', - required: false + id: 'showHidden', + description: 'Whether ot not to show hidden commands as well.', + match: 'flag', + flag: '--hidden', + slashType: 'BOOLEAN', + ownerOnly: true, + only: 'text', + optional: true } ], + slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] }); @@ -80,17 +79,17 @@ export default class HelpCommand extends BushCommand { const embed = new MessageEmbed() .setColor(util.colors.default) .setTitle(`${command.id} Command`) - .setDescription(`${command.description?.content ?? '*This command does not have a description.*'}`); - if (command.description?.usage?.length) { + .setDescription(`${command.description ?? '*This command does not have a description.*'}`); + if (command.usage?.length) { embed.addField( - `» Usage${command.description.usage.length > 1 ? 's' : ''}`, - command.description.usage.map((u) => `\`${u}\``).join('\n') + `» Usage${command.usage.length > 1 ? 's' : ''}`, + command.usage.map((u) => `\`${u}\``).join('\n') ); } - if (command.description?.examples?.length) { + if (command.examples?.length) { embed.addField( - `» Example${command.description.examples.length > 1 ? 's' : ''}`, - command.description.examples.map((u) => `\`${u}\``).join('\n') + `» Example${command.examples.length > 1 ? 's' : ''}`, + command.examples.map((u) => `\`${u}\``).join('\n') ); } if (command.aliases?.length > 1) embed.addField('» Aliases', `\`${command.aliases.join('` `')}\``); diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index 2a04a65..42b7fa4 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -6,11 +6,9 @@ export default class IconCommand extends BushCommand { super('icon', { aliases: ['icon', 'guildavatar', 'severicon', 'guildicon'], category: 'info', - description: { - content: "A command to get the server's icon", - usage: ['icon'], - examples: ['icon'] - }, + description: "A command to get the server's icon", + usage: ['icon'], + examples: ['icon'], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [], channel: 'guild', diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts index 935dca0..3f82245 100644 --- a/src/commands/info/links.ts +++ b/src/commands/info/links.ts @@ -7,11 +7,9 @@ export default class LinksCommand extends BushCommand { super('links', { aliases: ['links', 'invite', 'support'], category: 'info', - description: { - content: 'Sends bot links', - usage: ['links'], - examples: ['links'] - }, + description: 'Sends bot links', + usage: ['links'], + examples: ['links'], clientPermissions: (m) => util.clientSendAndPermCheck(m), userPermissions: [], slash: true diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 1d3f75a..619971f 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -6,11 +6,9 @@ export default class PingCommand extends BushCommand { super('ping', { aliases: ['ping'], category: 'info', - description: { - content: 'Gets the latency of the bot', - usage: ['ping'], - examples: ['ping'] - }, + description: 'Gets the latency of the bot', + usage: ['ping'], + examples: ['ping'], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 3cf27b6..29cd2ce 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -6,32 +6,22 @@ export default class PronounsCommand extends BushCommand { super('pronouns', { aliases: ['pronouns', 'pronoun'], category: 'info', - description: { - content: 'Finds the pronouns of a user using https://pronoundb.org.', - usage: ['pronouns <user>'], - examples: ['pronouns IRONM00N'] - }, + description: 'Finds the pronouns of a user using https://pronoundb.org.', + usage: ['pronouns <user>'], + examples: ['pronouns IRONM00N'], args: [ { id: 'user', + description: 'The user to get pronouns for.', type: 'globalUser', - prompt: { - start: 'Who would you like to view the pronouns of?', - retry: '{error} Choose a valid user to view the pronouns of.', - optional: true - } + prompt: 'Who would you like to view the pronouns of?', + retry: '{error} Choose a valid user to view the pronouns of.', + optional: true, + slashType: 'USER' } ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [], - slashOptions: [ - { - name: 'user', - description: 'The user to get pronouns for', - type: 'USER', - required: false - } - ], slash: true }); } diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index deb5692..bd0924f 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -21,33 +21,23 @@ export default class SnowflakeCommand extends BushCommand { super('snowflake', { aliases: ['snowflake', 'info', 'sf'], category: 'info', - description: { - content: 'Provides information about the specified Snowflake.', - usage: ['snowflake <snowflake>'], - examples: ['snowflake 322862723090219008'] - }, + description: 'Provides information about the specified Snowflake.', + usage: ['snowflake <snowflake>'], + examples: ['snowflake 322862723090219008'], args: [ { id: 'snowflake', + description: 'The snowflake you would like to get information about.', type: 'snowflake', - prompt: { - start: 'Enter the snowflake you would like to get information about.', - retry: '{error} Choose a valid snowflake.', - optional: false - } + prompt: 'What snowflake would you like to get information about?', + retry: '{error} Choose a valid snowflake.', + optional: false, + slashType: 'STRING' } ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [], - slash: true, - slashOptions: [ - { - name: 'snowflake', - description: 'The snowflake you would like to get information about.', - type: 'STRING', - required: true - } - ] + slash: true }); } public override async exec(message: BushMessage | BushSlashMessage, args: { snowflake: Snowflake }) { @@ -58,24 +48,26 @@ export default class SnowflakeCommand extends BushCommand { if (client.channels.cache.has(snowflake)) { const channel: Channel = client.channels.cache.get(snowflake)!; const channelInfo = [`**Type:** ${channel.type}`]; - if (['dm', 'group'].includes(channel.type)) { + if ((['DM', 'GROUP_DM'] as const).includes(channel.type)) { const _channel = channel as DMChannel; channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(_channel.recipient.tag)} (${_channel.recipient.id})`); snowflakeEmbed.setTitle( `:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\`` ); } else if ( - [ - 'GUILD_CATEGORY', - 'GUILD_NEWS', - 'GUILD_TEXT', - 'GUILD_VOICE', - 'GUILD_STORE', - 'GUILD_STAGE_VOICE', - 'GUILD_NEWS_THREAD', - 'GUILD_PUBLIC_THREAD', - 'GUILD_PRIVATE_THREAD' - ].includes(channel.type) + ( + [ + 'GUILD_CATEGORY', + 'GUILD_NEWS', + 'GUILD_TEXT', + 'GUILD_VOICE', + 'GUILD_STORE', + 'GUILD_STAGE_VOICE', + 'GUILD_NEWS_THREAD', + 'GUILD_PUBLIC_THREAD', + 'GUILD_PRIVATE_THREAD' + ] as const + ).includes(channel.type) ) { const _channel = channel as TextChannel | VoiceChannel | NewsChannel | StageChannel | CategoryChannel | StageChannel; channelInfo.push( diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 601e044..8ed6304 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -7,31 +7,22 @@ export default class UserInfoCommand extends BushCommand { super('userInfo', { aliases: ['user-info', 'user', 'u'], category: 'info', - description: { - content: 'Gives information about a specified user.', - usage: ['user-info [user]'], - examples: ['user-info 322862723090219008'] - }, + description: 'Gives information about a specified user.', + usage: ['user-info [user]'], + examples: ['user-info 322862723090219008'], args: [ { id: 'user', + description: 'The user you would like to find information about.', customType: util.arg.union('user', 'snowflake'), - prompt: { - start: 'What user would you like to find information about?', - retry: '{error} Choose a valid user to find information about.', - optional: true - } + readableType: 'user|snowflake', + prompt: 'What user would you like to find information about?', + retry: '{error} Choose a valid user to find information about.', + optional: true, + slashType: 'USER' } ], slash: true, - slashOptions: [ - { - name: 'user', - description: 'The user you would like to find information about.', - type: 'USER', - required: false - } - ], clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), userPermissions: [] }); @@ -108,7 +99,7 @@ export default class UserInfoCommand extends BushCommand { if (member?.displayHexColor) serverUserInfo.push(`**Display Color:** ${member.displayHexColor}`); if (user.id == '322862723090219008' && message.guild?.id == client.consts.mappings.guilds.bush) serverUserInfo.push(`**General Deletions:** 1⅓`); - if (['384620942577369088', '496409778822709251'].includes(user.id) && message.guild?.id == client.consts.mappings.guilds.bush) + if ((['384620942577369088', '496409778822709251'] as const).includes(user.id) && message.guild?.id == client.consts.mappings.guilds.bush) serverUserInfo.push(`**General Deletions:** ⅓`); if (member?.nickname) serverUserInfo.push(`**Nickname:** ${util.discord.escapeMarkdown(member?.nickname)}`); if (serverUserInfo.length) |