blob: 815b9e6817c3af9c3ea2dc83805a27931afb58cd [file] [log] [blame]
PineaFan538d3752023-01-12 21:48:23 +00001import { CommandInteraction, GuildMFALevel } from "discord.js";
TheCodedProff86ba092023-01-27 17:10:07 -05002import type { SlashCommandSubcommandBuilder } from "discord.js";
pineafan4edb7762022-06-26 19:21:04 +01003import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafanad54d752022-04-18 19:01:43 +01004import getEmojiByName from "../../utils/getEmojiByName.js";
Skyler Grey11236ba2022-08-08 21:13:33 +01005import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
pineafan63fc5e22022-08-04 22:04:10 +01006import client from "../../utils/client.js";
pineafanad54d752022-04-18 19:01:43 +01007
Skyler Grey75ea9172022-08-06 10:22:23 +01008const command = (builder: SlashCommandSubcommandBuilder) =>
9 builder.setName("about").setDescription("Shows info about the server");
pineafanad54d752022-04-18 19:01:43 +010010
PineaFan538d3752023-01-12 21:48:23 +000011const verificationTypes = {
12 0: "None - Unrestricted",
13 1: "Low - Must have a verified email",
14 2: "Medium - Must be registered for 5 minutes",
15 3: "High - Must be a member for 10 minutes",
16 4: "Highest - Must have a verified phone"
Skyler Greyda16adf2023-03-05 10:22:12 +000017};
PineaFan538d3752023-01-12 21:48:23 +000018
19const premiumTiers = {
20 0: "None",
21 1: "Tier 1",
22 2: "Tier 2",
23 3: "Tier 3"
Skyler Greyda16adf2023-03-05 10:22:12 +000024};
PineaFan538d3752023-01-12 21:48:23 +000025
26const filterLevels = {
27 0: "Disabled",
28 1: "Members without roles",
29 2: "All members"
Skyler Greyda16adf2023-03-05 10:22:12 +000030};
PineaFan538d3752023-01-12 21:48:23 +000031
pineafanbd02b4a2022-08-05 22:01:38 +010032const callback = async (interaction: CommandInteraction): Promise<void> => {
Skyler Grey75ea9172022-08-06 10:22:23 +010033 const guild = interaction.guild!;
pineafan63fc5e22022-08-04 22:04:10 +010034 const { renderUser, renderDelta } = client.logger;
Skyler Grey75ea9172022-08-06 10:22:23 +010035 interaction.reply({
36 embeds: [
37 new EmojiEmbed()
38 .setTitle("Server Info")
39 .setStatus("Success")
40 .setEmoji("GUILD.GREEN")
41 .setDescription(
42 generateKeyValueList({
43 name: guild.name,
44 id: `\`${guild.id}\``,
45 owner: `${renderUser((await guild.fetchOwner()).user)}`,
46 created: `${renderDelta(guild.createdTimestamp)}`,
47 emojis:
48 `${guild.emojis.cache.size}` +
49 (guild.emojis.cache.size > 1
50 ? `\n> ${guild.emojis.cache
Skyler Greyda16adf2023-03-05 10:22:12 +000051 .first(10)
52 .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
53 .join(" ")}` +
54 (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
Skyler Grey75ea9172022-08-06 10:22:23 +010055 : ""),
56 icon: `[Discord](${guild.iconURL()})`,
57 "2 factor authentication": `${
PineaFan538d3752023-01-12 21:48:23 +000058 guild.mfaLevel === GuildMFALevel.None
Skyler Grey75ea9172022-08-06 10:22:23 +010059 ? `${getEmojiByName("CONTROL.CROSS")} No`
60 : `${getEmojiByName("CONTROL.TICK")} Yes`
61 }`,
PineaFan538d3752023-01-12 21:48:23 +000062 "verification level": `${toCapitals(verificationTypes[guild.verificationLevel])}`,
63 "explicit content filter": `${filterLevels[guild.explicitContentFilter]}`,
64 "nitro boost level": `${premiumTiers[guild.premiumTier]}`,
Skyler Grey75ea9172022-08-06 10:22:23 +010065 channels: `${guild.channels.cache.size}`,
66 roles: `${guild.roles.cache.size}`,
67 members: `${guild.memberCount}`
68 })
69 )
PineaFan538d3752023-01-12 21:48:23 +000070 .setThumbnail(guild.iconURL())
Skyler Grey75ea9172022-08-06 10:22:23 +010071 ],
72 ephemeral: true
73 });
pineafan63fc5e22022-08-04 22:04:10 +010074};
pineafanad54d752022-04-18 19:01:43 +010075
pineafanad54d752022-04-18 19:01:43 +010076export { command };
77export { callback };