blob: 0a1cc6fcf04c0d1ff9c8eeb12947155e1d5614be [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";
Skyler Grey75ea9172022-08-06 10:22:23 +01006import generateKeyValueList, {
7 toCapitals
8} from "../../utils/generateKeyValueList.js";
pineafan63fc5e22022-08-04 22:04:10 +01009import client from "../../utils/client.js";
pineafanad54d752022-04-18 19:01:43 +010010
Skyler Grey75ea9172022-08-06 10:22:23 +010011const command = (builder: SlashCommandSubcommandBuilder) =>
12 builder.setName("about").setDescription("Shows info about the server");
pineafanad54d752022-04-18 19:01:43 +010013
pineafanbd02b4a2022-08-05 22:01:38 +010014const callback = async (interaction: CommandInteraction): Promise<void> => {
Skyler Grey75ea9172022-08-06 10:22:23 +010015 const guild = interaction.guild!;
pineafan63fc5e22022-08-04 22:04:10 +010016 const { renderUser, renderDelta } = client.logger;
Skyler Grey75ea9172022-08-06 10:22:23 +010017 interaction.reply({
18 embeds: [
19 new EmojiEmbed()
20 .setTitle("Server Info")
21 .setStatus("Success")
22 .setEmoji("GUILD.GREEN")
23 .setDescription(
24 generateKeyValueList({
25 name: guild.name,
26 id: `\`${guild.id}\``,
27 owner: `${renderUser((await guild.fetchOwner()).user)}`,
28 created: `${renderDelta(guild.createdTimestamp)}`,
29 emojis:
30 `${guild.emojis.cache.size}` +
31 (guild.emojis.cache.size > 1
32 ? `\n> ${guild.emojis.cache
33 .first(10)
34 .map(
35 (emoji) =>
36 `<${emoji.animated ? "a" : ""}:${
37 emoji.name
38 }:${emoji.id}>`
39 )
40 .join(" ")}` +
41 (guild.emojis.cache.size > 10
42 ? ` and ${
43 guild.emojis.cache.size - 10
44 } more`
45 : "")
46 : ""),
47 icon: `[Discord](${guild.iconURL()})`,
48 "2 factor authentication": `${
49 guild.mfaLevel === "NONE"
50 ? `${getEmojiByName("CONTROL.CROSS")} No`
51 : `${getEmojiByName("CONTROL.TICK")} Yes`
52 }`,
53 "verification level": `${toCapitals(
54 guild.verificationLevel
55 )}`,
56 "explicit content filter": `${toCapitals(
57 guild.explicitContentFilter
58 .toString()
59 .replace(/_/, " ")
60 )}`,
61 "nitro boost level": `${
62 guild.premiumTier !== "NONE"
63 ? guild.premiumTier.toString()[-1]
64 : "0"
65 }`,
66 channels: `${guild.channels.cache.size}`,
67 roles: `${guild.roles.cache.size}`,
68 members: `${guild.memberCount}`
69 })
70 )
71 .setThumbnail(guild.iconURL({ dynamic: true }))
72 ],
73 ephemeral: true
74 });
pineafan63fc5e22022-08-04 22:04:10 +010075};
pineafanad54d752022-04-18 19:01:43 +010076
Skyler Grey75ea9172022-08-06 10:22:23 +010077const check = (
78 _interaction: CommandInteraction,
79 _defaultCheck: WrappedCheck
80) => {
pineafanad54d752022-04-18 19:01:43 +010081 return true;
pineafan63fc5e22022-08-04 22:04:10 +010082};
pineafanad54d752022-04-18 19:01:43 +010083
84export { command };
85export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010086export { check };