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