import { CommandInteraction, Guild } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";

const command = (builder: SlashCommandSubcommandBuilder) =>
    builder.setName("about").setDescription("Shows info about the server");

const callback = async (interaction: CommandInteraction): Promise<void> => {
    const guild = interaction.guild!;
    const { renderUser, renderDelta } = client.logger;
    interaction.reply({
        embeds: [
            new EmojiEmbed()
                .setTitle("Server Info")
                .setStatus("Success")
                .setEmoji("GUILD.GREEN")
                .setDescription(
                    generateKeyValueList({
                        name: guild.name,
                        id: `\`${guild.id}\``,
                        owner: `${renderUser((await guild.fetchOwner()).user)}`,
                        created: `${renderDelta(guild.createdTimestamp)}`,
                        emojis:
                            `${guild.emojis.cache.size}` +
                            (guild.emojis.cache.size > 1
                                ? `\n> ${guild.emojis.cache
                                      .first(10)
                                      .map((emoji) => `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`)
                                      .join(" ")}` +
                                  (guild.emojis.cache.size > 10 ? ` and ${guild.emojis.cache.size - 10} more` : "")
                                : ""),
                        icon: `[Discord](${guild.iconURL()})`,
                        "2 factor authentication": `${
                            guild.mfaLevel === "NONE"
                                ? `${getEmojiByName("CONTROL.CROSS")} No`
                                : `${getEmojiByName("CONTROL.TICK")} Yes`
                        }`,
                        "verification level": `${toCapitals(guild.verificationLevel)}`,
                        "explicit content filter": `${toCapitals(
                            guild.explicitContentFilter.toString().replace(/_/, " ")
                        )}`,
                        "nitro boost level": `${guild.premiumTier !== "NONE" ? guild.premiumTier.toString()[-1] : "0"}`,
                        channels: `${guild.channels.cache.size}`,
                        roles: `${guild.roles.cache.size}`,
                        members: `${guild.memberCount}`
                    })
                )
                .setThumbnail(guild.iconURL({ dynamic: true }))
        ],
        ephemeral: true
    });
};

const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
    return true;
};

export { command };
export { callback };
export { check };
