diff options
Diffstat (limited to 'src/commands/info/guildInfo.ts')
-rw-r--r-- | src/commands/info/guildInfo.ts | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 572cf06..92999a5 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -1,9 +1,23 @@ -import { BushCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; +import { + akairo, + Arg, + BushCommand, + clientSendAndPermCheck, + colors, + emojis, + mappings, + timestampAndDelta, + type ArgType, + type CommandMessage, + type OptArgType, + type SlashMessage +} from '#lib'; import assert from 'assert'; import { ApplicationCommandOptionType, ChannelType, EmbedBuilder, + escapeMarkdown, Guild, GuildDefaultMessageNotifications, GuildExplicitContentFilter, @@ -29,7 +43,7 @@ export default class GuildInfoCommand extends BushCommand { { id: 'guild', description: 'The guild to find information about.', - type: util.arg.union('guild', 'snowflake'), + type: Arg.union('guild', 'snowflake'), readableType: 'guild|snowflake', prompt: 'What server would you like to find information about?', retry: '{error} Choose a valid server to find information about.', @@ -38,7 +52,7 @@ export default class GuildInfoCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } @@ -46,7 +60,7 @@ export default class GuildInfoCommand extends BushCommand { public override async exec(message: CommandMessage | SlashMessage, args: { guild: OptArgType<'guild' | 'snowflake'> }) { if (!args.guild && !message.inGuild()) { return await message.util.reply( - `${util.emojis.error} You must either provide an server to provide info about or run this command in a server.` + `${emojis.error} You must either provide an server to provide info about or run this command in a server.` ); } @@ -54,7 +68,7 @@ export default class GuildInfoCommand extends BushCommand { if (typeof guild === 'string') { const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => undefined); if (preview) guild = preview; - else return await message.util.reply(`${util.emojis.error} That guild is not discoverable or does not exist.`); + else return await message.util.reply(`${emojis.error} That guild is not discoverable or does not exist.`); } assert(guild); @@ -63,7 +77,7 @@ export default class GuildInfoCommand extends BushCommand { await guild.fetch(); } - const guildInfoEmbed = new EmbedBuilder().setTitle(guild.name).setColor(util.colors.default); + const guildInfoEmbed = new EmbedBuilder().setTitle(guild.name).setColor(colors.default); if (guild.icon) guildInfoEmbed.setThumbnail(guild.iconURL({ size: 2048, extension: 'png' })); await this.generateAboutField(guildInfoEmbed, guild); @@ -79,16 +93,16 @@ export default class GuildInfoCommand extends BushCommand { private generateDescription(embed: EmbedBuilder, guild: Guild | GuildPreview) { const description: string[] = []; - const otherEmojis = client.consts.mappings.otherEmojis; + const otherEmojis = mappings.otherEmojis; - const verifiedGuilds = Object.values(client.consts.mappings.guilds); + const verifiedGuilds = Object.values(mappings.guilds); if (verifiedGuilds.includes(guild.id as typeof verifiedGuilds[number])) description.push(otherEmojis.BushVerified); if (guild instanceof Guild) { if (guild.premiumTier !== GuildPremiumTier.None) description.push(otherEmojis[`BoostTier${guild.premiumTier}`]); } - const features = client.consts.mappings.features; + const features = mappings.features; const guildFeatures = guild.features.sort((a, b): number => { const aWeight = features[a]?.weight; const bWeight = features[b]?.weight; @@ -103,7 +117,7 @@ export default class GuildInfoCommand extends BushCommand { guildFeatures.forEach((feature) => { if (features[feature]?.emoji) description.push(`${features[feature].emoji}`); else if (features[feature]?.name) description.push(`\`${features[feature].name}\``); - else description.push(`\`${feature.charAt(0) + util.akairo.snakeToCamelCase(feature).substring(1)}\``); + else description.push(`\`${feature.charAt(0) + akairo.snakeToCamelCase(feature).substring(1)}\``); }); } @@ -125,12 +139,12 @@ export default class GuildInfoCommand extends BushCommand { ] as RTCRegion[]; guildAbout.push( - `**Owner:** ${util.discord.escapeMarkdown(guild.members.cache.get(guild.ownerId)?.user.tag ?? '¯\\_(ツ)_/¯')}`, - `**Created** ${util.timestampAndDelta(guild.createdAt, 'd')}`, - `**Members:** ${guild.memberCount.toLocaleString() ?? 0} (${util.emojis.onlineCircle} ${ + `**Owner:** ${escapeMarkdown(guild.members.cache.get(guild.ownerId)?.user.tag ?? '¯\\_(ツ)_/¯')}`, + `**Created** ${timestampAndDelta(guild.createdAt, 'd')}`, + `**Members:** ${guild.memberCount.toLocaleString() ?? 0} (${emojis.onlineCircle} ${ guild.approximatePresenceCount?.toLocaleString() ?? 0 - }, ${util.emojis.offlineCircle} ${(guild.memberCount - (guild.approximatePresenceCount ?? 0)).toLocaleString() ?? 0})`, - `**Regions:** ${guildRegions.map((region) => client.consts.mappings.regions[region] || region).join(', ')}` + }, ${emojis.offlineCircle} ${(guild.memberCount - (guild.approximatePresenceCount ?? 0)).toLocaleString() ?? 0})`, + `**Regions:** ${guildRegions.map((region) => mappings.regions[region] || region).join(', ')}` ); if (guild.premiumSubscriptionCount) guildAbout.push(`**Boosts:** Level ${guild.premiumTier} with ${guild.premiumSubscriptionCount ?? 0} boosts`); @@ -144,9 +158,9 @@ export default class GuildInfoCommand extends BushCommand { if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, extension: 'png' })})`); } else { guildAbout.push( - `**Members:** ${guild.approximateMemberCount?.toLocaleString() ?? 0} (${util.emojis.onlineCircle} ${ + `**Members:** ${guild.approximateMemberCount?.toLocaleString() ?? 0} (${emojis.onlineCircle} ${ guild.approximatePresenceCount?.toLocaleString() ?? 0 - }, ${util.emojis.offlineCircle} ${( + }, ${emojis.offlineCircle} ${( (guild.approximateMemberCount ?? 0) - (guild.approximatePresenceCount ?? 0) ).toLocaleString()})`, `**Emojis:** ${(guild as GuildPreview).emojis.size?.toLocaleString() ?? 0}`, @@ -173,7 +187,7 @@ export default class GuildInfoCommand extends BushCommand { ] as const ).map( (type) => - `${client.consts.mappings.otherEmojis[`Channel${type[0]}`]} ${guild.channels.cache + `${mappings.otherEmojis[`Channel${type[0]}`]} ${guild.channels.cache .filter((channel) => type[1].some((type) => channel.type === type)) .size.toLocaleString()}` ); |