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