blob: 23a53b7fc3b5d0d6e40659fee4c98e1bfde202c5 [file] [log] [blame]
PineaFan538d3752023-01-12 21:48:23 +00001import { CommandInteraction, GuildMFALevel } from "discord.js";
PineaFan64486c42022-12-28 09:21:04 +00002import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
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 +000011
12const verificationTypes = {
13 0: "None - Unrestricted",
14 1: "Low - Must have a verified email",
15 2: "Medium - Must be registered for 5 minutes",
16 3: "High - Must be a member for 10 minutes",
17 4: "Highest - Must have a verified phone"
18}
19
20const premiumTiers = {
21 0: "None",
22 1: "Tier 1",
23 2: "Tier 2",
24 3: "Tier 3"
25}
26
27const filterLevels = {
28 0: "Disabled",
29 1: "Members without roles",
30 2: "All members"
31}
32
pineafanbd02b4a2022-08-05 22:01:38 +010033const callback = async (interaction: CommandInteraction): Promise<void> => {
Skyler Grey75ea9172022-08-06 10:22:23 +010034 const guild = interaction.guild!;
pineafan63fc5e22022-08-04 22:04:10 +010035 const { renderUser, renderDelta } = client.logger;
Skyler Grey75ea9172022-08-06 10:22:23 +010036 interaction.reply({
37 embeds: [
38 new EmojiEmbed()
39 .setTitle("Server Info")
40 .setStatus("Success")
41 .setEmoji("GUILD.GREEN")
42 .setDescription(
43 generateKeyValueList({
44 name: guild.name,
45 id: `\`${guild.id}\``,
46 owner: `${renderUser((await guild.fetchOwner()).user)}`,
47 created: `${renderDelta(guild.createdTimestamp)}`,
48 emojis:
49 `${guild.emojis.cache.size}` +
50 (guild.emojis.cache.size > 1
51 ? `\n> ${guild.emojis.cache
PineaFan538d3752023-01-12 21:48:23 +000052 .first(10)
53 .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
54 .join(" ")}` +
55 (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
Skyler Grey75ea9172022-08-06 10:22:23 +010056 : ""),
57 icon: `[Discord](${guild.iconURL()})`,
58 "2 factor authentication": `${
PineaFan538d3752023-01-12 21:48:23 +000059 guild.mfaLevel === GuildMFALevel.None
Skyler Grey75ea9172022-08-06 10:22:23 +010060 ? `${getEmojiByName("CONTROL.CROSS")} No`
61 : `${getEmojiByName("CONTROL.TICK")} Yes`
62 }`,
PineaFan538d3752023-01-12 21:48:23 +000063 "verification level": `${toCapitals(verificationTypes[guild.verificationLevel])}`,
64 "explicit content filter": `${filterLevels[guild.explicitContentFilter]}`,
65 "nitro boost level": `${premiumTiers[guild.premiumTier]}`,
Skyler Grey75ea9172022-08-06 10:22:23 +010066 channels: `${guild.channels.cache.size}`,
67 roles: `${guild.roles.cache.size}`,
68 members: `${guild.memberCount}`
69 })
70 )
PineaFan538d3752023-01-12 21:48:23 +000071 .setThumbnail(guild.iconURL())
Skyler Grey75ea9172022-08-06 10:22:23 +010072 ],
73 ephemeral: true
74 });
pineafan63fc5e22022-08-04 22:04:10 +010075};
pineafanad54d752022-04-18 19:01:43 +010076
PineaFan0d06edc2023-01-17 22:10:31 +000077const check = () => {
pineafanad54d752022-04-18 19:01:43 +010078 return true;
pineafan63fc5e22022-08-04 22:04:10 +010079};
pineafanad54d752022-04-18 19:01:43 +010080
81export { command };
82export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010083export { check };