blob: 895d2ccfb1e71f7de6dff6bbcfb6851b15ce7a5d [file] [log] [blame]
pineafanad54d752022-04-18 19:01:43 +01001import Discord, { CommandInteraction, Guild, MessageActionRow, MessageButton } from "discord.js";
2import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
3import { WrappedCheck } from "jshaiku";
4import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
5import getEmojiByName from "../../utils/getEmojiByName.js";
6import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
PineappleFanb3dd83c2022-06-17 10:53:48 +01007import client from "../../utils/client.js"
pineafanad54d752022-04-18 19:01:43 +01008
9const command = (builder: SlashCommandSubcommandBuilder) => builder
10 .setName("about")
11 .setDescription("Shows info about the server")
12
13const callback = async (interaction: CommandInteraction) => {
14 let guild = interaction.guild as Guild;
PineappleFanb3dd83c2022-06-17 10:53:48 +010015 const { renderUser, renderDelta } = client.logger
pineafanad54d752022-04-18 19:01:43 +010016 interaction.reply({embeds: [new generateEmojiEmbed()
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": `${guild.emojis.cache.size}` + (guild.emojis.cache.size > 1 ? `\n> ${
27 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` : ``) : ""),
30 "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)}`,
33 "explicit content filter": `${toCapitals(guild.explicitContentFilter.toString().replace(/_/, " ", ))}`,
34 "nitro boost level": `${guild.premiumTier != "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
35 "channels": `${guild.channels.cache.size}`,
36 "roles": `${guild.roles.cache.size}`,
37 "members": `${guild.memberCount}`,
38 })
39 )
40 .setThumbnail(guild.iconURL({dynamic: true}))
41 ], ephemeral: true});
42}
43
44const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
45 return true;
46}
47
48export { command };
49export { callback };
50export { check };