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"; |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +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") |
| 11 | .setDescription("Shows info about the server") |
| 12 | |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 13 | const callback = async (interaction: CommandInteraction): Promise<any> => { |
pineafan | ad54d75 | 2022-04-18 19:01:43 +0100 | [diff] [blame] | 14 | let guild = interaction.guild as Guild; |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +0100 | [diff] [blame] | 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> ${ |
| 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(/_/, " ", ))}`, |
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}`, |
| 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 }; |