blob: c0a2edee02ad22c192bef6b5d133fb7cec2b4fbc [file] [log] [blame]
pineafanbd02b4a2022-08-05 22:01:38 +01001import { CommandInteraction, Guild } 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";
6import 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
9const command = (builder: SlashCommandSubcommandBuilder) => builder
10 .setName("about")
pineafan63fc5e22022-08-04 22:04:10 +010011 .setDescription("Shows info about the server");
pineafanad54d752022-04-18 19:01:43 +010012
pineafanbd02b4a2022-08-05 22:01:38 +010013const callback = async (interaction: CommandInteraction): Promise<void> => {
pineafan63fc5e22022-08-04 22:04:10 +010014 const guild = interaction.guild as Guild;
15 const { renderUser, renderDelta } = client.logger;
pineafan4edb7762022-06-26 19:21:04 +010016 interaction.reply({embeds: [new EmojiEmbed()
pineafanad54d752022-04-18 19:01:43 +010017 .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": `${guild.emojis.cache.size}` + (guild.emojis.cache.size > 1 ? `\n> ${
pineafan63fc5e22022-08-04 22:04:10 +010027 guild.emojis.cache.first(10).map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`).join(" ")
28 }` +
29 (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "") : ""),
pineafanad54d752022-04-18 19:01:43 +010030 "icon": `[Discord](${guild.iconURL()})`,
31 "2 factor authentication": `${guild.mfaLevel === "NONE" ? `${getEmojiByName("CONTROL.CROSS")} No` : `${getEmojiByName("CONTROL.TICK")} Yes`}`,
32 "verification level": `${toCapitals(guild.verificationLevel)}`,
pineafan63fc5e22022-08-04 22:04:10 +010033 "explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " " ))}`,
pineafane23c4ec2022-07-27 21:56:27 +010034 "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
pineafanad54d752022-04-18 19:01:43 +010035 "channels": `${guild.channels.cache.size}`,
36 "roles": `${guild.roles.cache.size}`,
pineafan63fc5e22022-08-04 22:04:10 +010037 "members": `${guild.memberCount}`
pineafanad54d752022-04-18 19:01:43 +010038 })
39 )
40 .setThumbnail(guild.iconURL({dynamic: true}))
41 ], ephemeral: true});
pineafan63fc5e22022-08-04 22:04:10 +010042};
pineafanad54d752022-04-18 19:01:43 +010043
pineafanbd02b4a2022-08-05 22:01:38 +010044const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
pineafanad54d752022-04-18 19:01:43 +010045 return true;
pineafan63fc5e22022-08-04 22:04:10 +010046};
pineafanad54d752022-04-18 19:01:43 +010047
48export { command };
49export { callback };
50export { check };