blob: b8957681dde4f85c9f5a6558eb48c5b2b35ce0c8 [file] [log] [blame]
PineaFan64486c42022-12-28 09:21:04 +00001import type { CommandInteraction } from "discord.js";
2import 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
pineafanbd02b4a2022-08-05 22:01:38 +010011const callback = async (interaction: CommandInteraction): Promise<void> => {
Skyler Grey75ea9172022-08-06 10:22:23 +010012 const guild = interaction.guild!;
pineafan63fc5e22022-08-04 22:04:10 +010013 const { renderUser, renderDelta } = client.logger;
Skyler Grey75ea9172022-08-06 10:22:23 +010014 interaction.reply({
15 embeds: [
16 new EmojiEmbed()
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:
27 `${guild.emojis.cache.size}` +
28 (guild.emojis.cache.size > 1
29 ? `\n> ${guild.emojis.cache
30 .first(10)
Skyler Grey11236ba2022-08-08 21:13:33 +010031 .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
Skyler Grey75ea9172022-08-06 10:22:23 +010032 .join(" ")}` +
Skyler Grey11236ba2022-08-08 21:13:33 +010033 (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
Skyler Grey75ea9172022-08-06 10:22:23 +010034 : ""),
35 icon: `[Discord](${guild.iconURL()})`,
36 "2 factor authentication": `${
37 guild.mfaLevel === "NONE"
38 ? `${getEmojiByName("CONTROL.CROSS")} No`
39 : `${getEmojiByName("CONTROL.TICK")} Yes`
40 }`,
Skyler Grey11236ba2022-08-08 21:13:33 +010041 "verification level": `${toCapitals(guild.verificationLevel)}`,
Skyler Grey75ea9172022-08-06 10:22:23 +010042 "explicit content filter": `${toCapitals(
Skyler Grey11236ba2022-08-08 21:13:33 +010043 guild.explicitContentFilter.toString().replace(/_/, " ")
Skyler Grey75ea9172022-08-06 10:22:23 +010044 )}`,
Skyler Grey11236ba2022-08-08 21:13:33 +010045 "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
Skyler Grey75ea9172022-08-06 10:22:23 +010046 channels: `${guild.channels.cache.size}`,
47 roles: `${guild.roles.cache.size}`,
48 members: `${guild.memberCount}`
49 })
50 )
51 .setThumbnail(guild.iconURL({ dynamic: true }))
52 ],
53 ephemeral: true
54 });
pineafan63fc5e22022-08-04 22:04:10 +010055};
pineafanad54d752022-04-18 19:01:43 +010056
PineaFan64486c42022-12-28 09:21:04 +000057const check = (_interaction: CommandInteraction) => {
pineafanad54d752022-04-18 19:01:43 +010058 return true;
pineafan63fc5e22022-08-04 22:04:10 +010059};
pineafanad54d752022-04-18 19:01:43 +010060
61export { command };
62export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010063export { check };