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"; |
| 4 | import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
| 5 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
| 6 | import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js"; |
| 7 | |
| 8 | const command = (builder: SlashCommandSubcommandBuilder) => builder |
| 9 | .setName("about") |
| 10 | .setDescription("Shows info about the server") |
| 11 | |
| 12 | const callback = async (interaction: CommandInteraction) => { |
| 13 | let guild = interaction.guild as Guild; |
| 14 | // @ts-ignore |
| 15 | const { renderUser, renderDelta } = interaction.client.logger |
| 16 | interaction.reply({embeds: [new generateEmojiEmbed() |
| 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> ${ |
| 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` : ``) : ""), |
| 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)}`, |
| 33 | "explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " ", ))}`, |
| 34 | "nitro boost level": `${guild.premiumTier != "NONE" ? guild.premiumTier.toString()[-1] : "0"}`, |
| 35 | "channels": `${guild.channels.cache.size}`, |
| 36 | "roles": `${guild.roles.cache.size}`, |
| 37 | "members": `${guild.memberCount}`, |
| 38 | }) |
| 39 | ) |
| 40 | .setThumbnail(guild.iconURL({dynamic: true})) |
| 41 | ], ephemeral: true}); |
| 42 | } |
| 43 | |
| 44 | const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | export { command }; |
| 49 | export { callback }; |
| 50 | export { check }; |