pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame^] | 1 | import { CommandInteraction } from "discord.js"; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 2 | import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
| 3 | import { WrappedCheck } from "jshaiku"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 4 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 5 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 6 | import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 7 | import client from "../../utils/client.js"; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 8 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 9 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 10 | builder.setName("about").setDescription("Shows info about the server"); |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 11 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 12 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 13 | const guild = interaction.guild!; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 14 | const { renderUser, renderDelta } = client.logger; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 15 | interaction.reply({ |
| 16 | embeds: [ |
| 17 | new EmojiEmbed() |
| 18 | .setTitle("Server Info") |
| 19 | .setStatus("Success") |
| 20 | .setEmoji("GUILD.GREEN") |
| 21 | .setDescription( |
| 22 | generateKeyValueList({ |
| 23 | name: guild.name, |
| 24 | id: `\`${guild.id}\``, |
| 25 | owner: `${renderUser((await guild.fetchOwner()).user)}`, |
| 26 | created: `${renderDelta(guild.createdTimestamp)}`, |
| 27 | emojis: |
| 28 | `${guild.emojis.cache.size}` + |
| 29 | (guild.emojis.cache.size > 1 |
| 30 | ? `\n> ${guild.emojis.cache |
| 31 | .first(10) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 32 | .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 33 | .join(" ")}` + |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 34 | (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 35 | : ""), |
| 36 | icon: `[Discord](${guild.iconURL()})`, |
| 37 | "2 factor authentication": `${ |
| 38 | guild.mfaLevel === "NONE" |
| 39 | ? `${getEmojiByName("CONTROL.CROSS")} No` |
| 40 | : `${getEmojiByName("CONTROL.TICK")} Yes` |
| 41 | }`, |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 42 | "verification level": `${toCapitals(guild.verificationLevel)}`, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 43 | "explicit content filter": `${toCapitals( |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 44 | guild.explicitContentFilter.toString().replace(/_/, " ") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 45 | )}`, |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 46 | "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`, |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 47 | channels: `${guild.channels.cache.size}`, |
| 48 | roles: `${guild.roles.cache.size}`, |
| 49 | members: `${guild.memberCount}` |
| 50 | }) |
| 51 | ) |
| 52 | .setThumbnail(guild.iconURL({ dynamic: true })) |
| 53 | ], |
| 54 | ephemeral: true |
| 55 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 56 | }; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 57 | |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 58 | const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => { |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 59 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 60 | }; |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 61 | |
| 62 | export { command }; |
| 63 | export { callback }; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 64 | export { check }; |