| import { CommandInteraction, GuildMFALevel } from "discord.js"; |
| import type { SlashCommandSubcommandBuilder } from "discord.js"; |
| import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
| import getEmojiByName from "../../utils/getEmojiByName.js"; |
| import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js"; |
| import client from "../../utils/client.js"; |
| |
| const command = (builder: SlashCommandSubcommandBuilder) => |
| builder.setName("about").setDescription("Shows info about the server"); |
| |
| const verificationTypes = { |
| 0: "None - Unrestricted", |
| 1: "Low - Must have a verified email", |
| 2: "Medium - Must be registered for 5 minutes", |
| 3: "High - Must be a member for 10 minutes", |
| 4: "Highest - Must have a verified phone" |
| }; |
| |
| const premiumTiers = { |
| 0: "None", |
| 1: "Tier 1", |
| 2: "Tier 2", |
| 3: "Tier 3" |
| }; |
| |
| const filterLevels = { |
| 0: "Disabled", |
| 1: "Members without roles", |
| 2: "All members" |
| }; |
| |
| const callback = async (interaction: CommandInteraction): Promise<void> => { |
| const guild = interaction.guild!; |
| const { renderUser, renderDelta } = client.logger; |
| await interaction.reply({ |
| embeds: [ |
| new EmojiEmbed() |
| .setTitle("Server Info") |
| .setStatus("Success") |
| .setEmoji("GUILD.GREEN") |
| .setDescription( |
| generateKeyValueList({ |
| name: guild.name, |
| id: `\`${guild.id}\``, |
| owner: `${renderUser((await guild.fetchOwner()).user)}`, |
| created: `${renderDelta(guild.createdTimestamp)}`, |
| emojis: |
| `${guild.emojis.cache.size}` + |
| (guild.emojis.cache.size > 1 |
| ? `\n> ${guild.emojis.cache |
| .first(10) |
| .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`) |
| .join(" ")}` + |
| (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "") |
| : ""), |
| icon: `[Discord](${guild.iconURL()})`, |
| "2 factor authentication": `${ |
| guild.mfaLevel === GuildMFALevel.None |
| ? `${getEmojiByName("CONTROL.CROSS")} No` |
| : `${getEmojiByName("CONTROL.TICK")} Yes` |
| }`, |
| "verification level": `${toCapitals(verificationTypes[guild.verificationLevel])}`, |
| "explicit content filter": `${filterLevels[guild.explicitContentFilter]}`, |
| "nitro boost level": `${premiumTiers[guild.premiumTier]}`, |
| channels: `${guild.channels.cache.size}`, |
| roles: `${guild.roles.cache.size}`, |
| members: `${guild.memberCount}` |
| }) |
| ) |
| .setThumbnail(guild.iconURL()) |
| ], |
| ephemeral: true |
| }); |
| }; |
| |
| export { command }; |
| export { callback }; |