PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 1 | import { CommandInteraction, GuildMFALevel } from "discord.js"; |
TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 2 | import type { SlashCommandSubcommandBuilder } from "discord.js"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 3 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 4 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 5 | import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 6 | import client from "../../utils/client.js"; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 7 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 8 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 9 | builder.setName("about").setDescription("Shows info about the server"); |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 10 | |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 11 | const verificationTypes = { |
| 12 | 0: "None - Unrestricted", |
| 13 | 1: "Low - Must have a verified email", |
| 14 | 2: "Medium - Must be registered for 5 minutes", |
| 15 | 3: "High - Must be a member for 10 minutes", |
| 16 | 4: "Highest - Must have a verified phone" |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 17 | }; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 18 | |
| 19 | const premiumTiers = { |
| 20 | 0: "None", |
| 21 | 1: "Tier 1", |
| 22 | 2: "Tier 2", |
| 23 | 3: "Tier 3" |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 24 | }; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 25 | |
| 26 | const filterLevels = { |
| 27 | 0: "Disabled", |
| 28 | 1: "Members without roles", |
| 29 | 2: "All members" |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 30 | }; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 31 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 32 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 33 | const guild = interaction.guild!; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 34 | const { renderUser, renderDelta } = client.logger; |
Skyler Grey | f4f21c4 | 2023-03-08 14:36:29 +0000 | [diff] [blame^] | 35 | await interaction.reply({ |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 36 | embeds: [ |
| 37 | new EmojiEmbed() |
| 38 | .setTitle("Server Info") |
| 39 | .setStatus("Success") |
| 40 | .setEmoji("GUILD.GREEN") |
| 41 | .setDescription( |
| 42 | generateKeyValueList({ |
| 43 | name: guild.name, |
| 44 | id: `\`${guild.id}\``, |
| 45 | owner: `${renderUser((await guild.fetchOwner()).user)}`, |
| 46 | created: `${renderDelta(guild.createdTimestamp)}`, |
| 47 | emojis: |
| 48 | `${guild.emojis.cache.size}` + |
| 49 | (guild.emojis.cache.size > 1 |
| 50 | ? `\n> ${guild.emojis.cache |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 51 | .first(10) |
| 52 | .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`) |
| 53 | .join(" ")}` + |
| 54 | (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 55 | : ""), |
| 56 | icon: `[Discord](${guild.iconURL()})`, |
| 57 | "2 factor authentication": `${ |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 58 | guild.mfaLevel === GuildMFALevel.None |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 59 | ? `${getEmojiByName("CONTROL.CROSS")} No` |
| 60 | : `${getEmojiByName("CONTROL.TICK")} Yes` |
| 61 | }`, |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 62 | "verification level": `${toCapitals(verificationTypes[guild.verificationLevel])}`, |
| 63 | "explicit content filter": `${filterLevels[guild.explicitContentFilter]}`, |
| 64 | "nitro boost level": `${premiumTiers[guild.premiumTier]}`, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 65 | channels: `${guild.channels.cache.size}`, |
| 66 | roles: `${guild.roles.cache.size}`, |
| 67 | members: `${guild.memberCount}` |
| 68 | }) |
| 69 | ) |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 70 | .setThumbnail(guild.iconURL()) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 71 | ], |
| 72 | ephemeral: true |
| 73 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 74 | }; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 75 | |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 76 | export { command }; |
| 77 | export { callback }; |