blob: 116071e5076630f0474ba2dcd493a906a0ac4047 [file] [log] [blame]
pineafan3a02ea32022-08-11 21:35:04 +01001import { CommandInteraction } from "discord.js";
pineafanad54d752022-04-18 19:01:43 +01002import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
3import { WrappedCheck } from "jshaiku";
pineafan4edb7762022-06-26 19:21:04 +01004import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafanad54d752022-04-18 19:01:43 +01005import getEmojiByName from "../../utils/getEmojiByName.js";
Skyler Grey11236ba2022-08-08 21:13:33 +01006import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
pineafan63fc5e22022-08-04 22:04:10 +01007import client from "../../utils/client.js";
pineafanad54d752022-04-18 19:01:43 +01008
Skyler Grey75ea9172022-08-06 10:22:23 +01009const command = (builder: SlashCommandSubcommandBuilder) =>
10 builder.setName("about").setDescription("Shows info about the server");
pineafanad54d752022-04-18 19:01:43 +010011
pineafanbd02b4a2022-08-05 22:01:38 +010012const callback = async (interaction: CommandInteraction): Promise<void> => {
Skyler Grey75ea9172022-08-06 10:22:23 +010013 const guild = interaction.guild!;
pineafan63fc5e22022-08-04 22:04:10 +010014 const { renderUser, renderDelta } = client.logger;
Skyler Grey75ea9172022-08-06 10:22:23 +010015 interaction.reply({
16 embeds: [
17 new EmojiEmbed()
18 .setTitle("Server Info")
19 .setStatus("Success")
20 .setEmoji("GUILD.GREEN")
21 .setDescription(
22 generateKeyValueList({
23 name: guild.name,
24 id: `\`${guild.id}\``,
25 owner: `${renderUser((await guild.fetchOwner()).user)}`,
26 created: `${renderDelta(guild.createdTimestamp)}`,
27 emojis:
28 `${guild.emojis.cache.size}` +
29 (guild.emojis.cache.size > 1
30 ? `\n> ${guild.emojis.cache
31 .first(10)
Skyler Grey11236ba2022-08-08 21:13:33 +010032 .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
Skyler Grey75ea9172022-08-06 10:22:23 +010033 .join(" ")}` +
Skyler Grey11236ba2022-08-08 21:13:33 +010034 (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
Skyler Grey75ea9172022-08-06 10:22:23 +010035 : ""),
36 icon: `[Discord](${guild.iconURL()})`,
37 "2 factor authentication": `${
38 guild.mfaLevel === "NONE"
39 ? `${getEmojiByName("CONTROL.CROSS")} No`
40 : `${getEmojiByName("CONTROL.TICK")} Yes`
41 }`,
Skyler Grey11236ba2022-08-08 21:13:33 +010042 "verification level": `${toCapitals(guild.verificationLevel)}`,
Skyler Grey75ea9172022-08-06 10:22:23 +010043 "explicit content filter": `${toCapitals(
Skyler Grey11236ba2022-08-08 21:13:33 +010044 guild.explicitContentFilter.toString().replace(/_/, " ")
Skyler Grey75ea9172022-08-06 10:22:23 +010045 )}`,
Skyler Grey11236ba2022-08-08 21:13:33 +010046 "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
Skyler Grey75ea9172022-08-06 10:22:23 +010047 channels: `${guild.channels.cache.size}`,
48 roles: `${guild.roles.cache.size}`,
49 members: `${guild.memberCount}`
50 })
51 )
52 .setThumbnail(guild.iconURL({ dynamic: true }))
53 ],
54 ephemeral: true
55 });
pineafan63fc5e22022-08-04 22:04:10 +010056};
pineafanad54d752022-04-18 19:01:43 +010057
Skyler Grey11236ba2022-08-08 21:13:33 +010058const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
pineafanad54d752022-04-18 19:01:43 +010059 return true;
pineafan63fc5e22022-08-04 22:04:10 +010060};
pineafanad54d752022-04-18 19:01:43 +010061
62export { command };
63export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010064export { check };