import { CommandInteraction, MessageEmbed, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import readConfig from "../../utils/readConfig.js";
import { toHexArray, toHexInteger, logs } from "../../utils/calculate.js"
import { capitalize } from "../../utils/generateKeyValueList.js";

const command = (builder: SlashCommandSubcommandBuilder) =>
    builder
    .setName("menu")
    .setDescription("Shows a full UI of all settings")

const callback = async (interaction: CommandInteraction) => {
    return
    let config = await readConfig(interaction.guild.id);

    let currentValues = toHexArray(config.logging.log.toLog);

    let toLogDropdownOptions = []

    for(let i of logs) {
        if(currentValues.includes(i)) {
            toLogDropdownOptions.push({
                name: capitalize(i),
                value: i,
                emoji: "TICK"
            })
        } else {
            toLogDropdownOptions.push({
                label: capitalize(i),
                value: i,
                emoji: "CROSS"
            })
        }
    }

    let toLogDropdown = new MessageSelectMenu()
        .setCustomId("tolog")
        .setMaxValues(22)
        .addOptions()

    let embed = new MessageEmbed()

    interaction.reply("Command incomplete [settings/all]");
}

const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
    return true;
}

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