diff options
Diffstat (limited to 'src/commands/info')
-rw-r--r-- | src/commands/info/botInfo.ts | 2 | ||||
-rw-r--r-- | src/commands/info/guildInfo.ts | 46 | ||||
-rw-r--r-- | src/commands/info/help.ts | 76 | ||||
-rw-r--r-- | src/commands/info/pronouns.ts | 2 | ||||
-rw-r--r-- | src/commands/info/snowflake.ts | 16 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 9 |
6 files changed, 89 insertions, 62 deletions
diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 04a1b14..833ed96 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,7 +1,7 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import { MessageEmbed, version as discordJSVersion } from 'discord.js'; import * as os from 'os'; -const {default: prettyBytes} = await import('pretty-bytes') +const { default: prettyBytes } = await import('pretty-bytes'); export default class BotInfoCommand extends BushCommand { public constructor() { diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index ef1c232..47a8281 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -1,5 +1,13 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Constants, Guild, MessageEmbed, type BaseGuildVoiceChannel, type GuildPreview, type Snowflake, type Vanity } from 'discord.js'; +import { + Constants, + Guild, + MessageEmbed, + type BaseGuildVoiceChannel, + type GuildPreview, + type Snowflake, + type Vanity +} from 'discord.js'; export default class GuildInfoCommand extends BushCommand { public constructor() { @@ -66,17 +74,17 @@ export default class GuildInfoCommand extends BushCommand { 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[]).map( - (type)=>`${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}` - ) + 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[] + ).map((type) => `${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`); const guildRegions = [ ...new Set( @@ -105,8 +113,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 } + 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 + } 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 f956405..3bf8f5e 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -44,35 +44,7 @@ export default class HelpCommand extends BushCommand { args: { command: BushCommand | string; showHidden?: boolean } ) { const prefix = util.prefix(message); - const row = new MessageActionRow(); - - if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${ - client.user!.id - }&permissions=5368709119918&scope=bot%20applications.commands` - }) - ); - } - if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) { - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Support Server', - url: client.config.supportGuild.invite - }) - ); - } - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'GitHub', - url: packageDotJSON.repository - }) - ); + const row = this.addLinks(message); const isOwner = client.isOwner(message.author); const isSuperUser = client.isSuperUser(message.author); @@ -91,17 +63,13 @@ export default class HelpCommand extends BushCommand { if (command.hidden && !args.showHidden) return false; if (command.channel == 'guild' && !message.guild && !args.showHidden) return false; if (command.ownerOnly && !isOwner) return false; - if (command.superUserOnly && !isSuperUser) { - return false; - } + if (command.superUserOnly && !isSuperUser) return false; return !(command.restrictedGuilds?.includes(message.guild?.id ?? '') === false && !args.showHidden); }); const categoryNice = category.id - .replace(/(\b\w)/gi, (lc): string => lc.toUpperCase()) - .replace(/'(S)/g, (letter): string => letter.toLowerCase()); - const categoryCommands = categoryFilter - .filter((cmd): boolean => cmd.aliases.length > 0) - .map((cmd): string => `\`${cmd.aliases[0]}\``); + .replace(/(\b\w)/gi, (lc) => lc.toUpperCase()) + .replace(/'(S)/g, (letter) => letter.toLowerCase()); + const categoryCommands = categoryFilter.filter((cmd) => cmd.aliases.length > 0).map((cmd) => `\`${cmd.aliases[0]}\``); if (categoryCommands.length > 0) { embed.addField(`${categoryNice}`, `${categoryCommands.join(' ')}`); } @@ -153,4 +121,38 @@ export default class HelpCommand extends BushCommand { return await message.util.reply({ embeds: [embed], components: [row] }); } + + private addLinks(message: BushMessage | BushSlashMessage) { + const row = new MessageActionRow(); + + if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'Invite Me', + url: `https://discord.com/api/oauth2/authorize?client_id=${ + client.user!.id + }&permissions=5368709119918&scope=bot%20applications.commands` + }) + ); + } + if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) { + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'Support Server', + url: client.config.supportGuild.invite + }) + ); + } + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'GitHub', + url: packageDotJSON.repository + }) + ); + + return row; + } } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index a7df5aa..3cf27b6 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -39,7 +39,7 @@ export default class PronounsCommand extends BushCommand { const user = args.user ?? message.author; const author = user.id === message.author.id; - if (message.util.isSlashMessage(message)) await message.interaction.deferReply() + if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); const pronouns = await util.getPronounsOf(user); if (!pronouns) { diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index 3b1a073..deb5692 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -6,7 +6,8 @@ import { type CategoryChannel, type Channel, type DeconstructedSnowflake, - type DMChannel, type Guild, + type DMChannel, + type Guild, type NewsChannel, type Role, type Snowflake, @@ -60,7 +61,9 @@ export default class SnowflakeCommand extends BushCommand { if (['dm', 'group'].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]\``); + snowflakeEmbed.setTitle( + `:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\`` + ); } else if ( [ 'GUILD_CATEGORY', @@ -89,7 +92,9 @@ export default class SnowflakeCommand extends BushCommand { const guild: Guild = client.guilds.cache.get(snowflake)!; const guildInfo = [ `**Name:** ${util.discord.escapeMarkdown(guild.name)}`, - `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId})`, + `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${ + guild.ownerId + })`, `**Members:** ${guild.memberCount?.toLocaleString()}` ]; if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!); @@ -110,7 +115,10 @@ export default class SnowflakeCommand extends BushCommand { // Emoji if (client.emojis.cache.has(snowflake)) { const emoji = client.emojis.cache.get(snowflake)!; - const emojiInfo = [`**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, `**Animated:** ${emoji.animated}`]; + const emojiInfo = [ + `**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, + `**Animated:** ${emoji.animated}` + ]; if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n')); snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} \`[Emoji]\``); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 49c23c9..601e044 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -53,9 +53,7 @@ export default class UserInfoCommand extends BushCommand { const userEmbed: MessageEmbed = new MessageEmbed() .setTitle(util.discord.escapeMarkdown(user.tag)) - .setThumbnail( - user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true }) - ) + .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true })) .setTimestamp(); // Flags @@ -95,7 +93,7 @@ export default class UserInfoCommand extends BushCommand { const generalInfo = [`**Mention:** <@${user.id}>`, `**ID:** ${user.id}`, `**Created:** ${createdAt} (${createdAtDelta} ago)`]; if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`); if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ dynamic: true, format: 'png', size: 4096 })})`); - const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); + const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`); userEmbed.addField('» General Info', generalInfo.join('\n')); @@ -137,7 +135,8 @@ export default class UserInfoCommand extends BushCommand { presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${util.oxford(devices, 'and', '')}`); if (activitiesNames.length) presenceInfo.push(`**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${util.oxford(activitiesNames, 'and', '')}`); - if (customStatus && customStatus.length) presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`); + if (customStatus && customStatus.length) + presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`); userEmbed.addField('» Presence', presenceInfo.join('\n')); enum statusEmojis { |