import { callback as roleMenu } from "../actions/roleMenu.js";
import verify from "../reflex/verify.js";
import create from "../actions/tickets/create.js";
import close from "../actions/tickets/delete.js";
import createTranscript from "../premium/createTranscript.js";

import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, Interaction, InteractionEditReplyOptions, ModalBuilder, ModalSubmitInteraction, TextInputBuilder, TextInputStyle } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";

import { callback as banCallback, check as banCheck } from "../commands/mod/ban.js";
import { callback as kickCallback, check as kickCheck } from "../commands/mod/kick.js";
import { callback as muteCallback, check as muteCheck } from "../commands/mod/mute.js";
import { callback as nicknameCallback, check as nicknameCheck } from "../commands/mod/nick.js";
import { callback as warnCallback, check as warnCheck } from "../commands/mod/warn.js";
import client from "../utils/client.js";

export const event = "interactionCreate";

async function errorMessage(interaction: ButtonInteraction, message: string) {
    await interaction.reply({
        embeds: [new EmojiEmbed().setDescription(message).setStatus("Danger")],
        ephemeral: true,
        components: []
    });
}

async function interactionCreate(interaction: Interaction) {
    if (interaction.isButton()) {
        if (interaction.customId.endsWith(":Suggestion")) {
            const value = interaction.customId.startsWith("accept") || interaction.customId.startsWith("implement") ? true : false
            return await modifySuggestion(interaction, value);
        }
        switch (interaction.customId) {
            case "rolemenu": {
                return await roleMenu(interaction);
            }
            case "verifybutton": {
                return await verify(interaction);
            }
            case "createticket": {
                return await create(interaction);
            }
            case "closeticket": {
                return await close(interaction);
            }
            case "createtranscript": {
                return await createTranscript(interaction);
            }
        }
        // Mod actions
        if (interaction.customId.startsWith("mod:")) {
            const action = interaction.customId.split(":")[1];
            const memberId = interaction.customId.split(":")[2];
            const member = await interaction.guild?.members.fetch(memberId!);
            switch (action) {
                case "kick": {
                    const check = kickCheck(interaction, false, member);
                    if (check !== true) return await errorMessage(interaction, check!);
                    return await kickCallback(interaction, member);
                }
                case "ban": {
                    const check = banCheck(interaction, false, member);
                    if (check !== true) return await errorMessage(interaction, check!);
                    return await banCallback(interaction, member);
                }
                case "mute": {
                    const check = muteCheck(interaction, false, member);
                    if (check !== true) return await errorMessage(interaction, check!);
                    return await muteCallback(interaction, member);
                }
                case "nickname": {
                    const check = nicknameCheck(interaction, false, member);
                    if (check !== true) return await errorMessage(interaction, check || "Something went wrong");
                    return await nicknameCallback(interaction, member);
                }
                case "warn": {
                    const check = warnCheck(interaction, false, member);
                    if (check !== true) return await errorMessage(interaction, check!);
                    return await warnCallback(interaction, member);
                }
            }
        }
    }
}

const getReason = async (buttonInteraction: ButtonInteraction, prompt: string) => {
    const modal = new ModalBuilder()
        .addComponents(
            new ActionRowBuilder<TextInputBuilder>().addComponents(
                new TextInputBuilder()
                    .setStyle(TextInputStyle.Paragraph)
                    .setLabel(prompt)
                    .setCustomId("typed")
            )
        )
        .setTitle("Reason")
        .setCustomId("modal");
    await buttonInteraction.showModal(modal);
    let out: ModalSubmitInteraction;
    try {
        out = await buttonInteraction.awaitModalSubmit({
            filter: (i) => i.customId === "modal" && i.user.id === buttonInteraction.user.id,
            time: 300000
        });
    } catch {
        return null;
    }
    await out.deferUpdate();
    return out.fields.getTextInputValue("typed");
}

async function modifySuggestion(interaction: ButtonInteraction, accept: boolean) {
    const message = interaction.message;
    await message.fetch();
    if (message.embeds.length === 0) return;
    const embed = message.embeds[0]!;
    const issueNum = embed.footer!.text
    if(!issueNum) return;
    const issue = {
        owner: "ClicksMinutePer",
        repo: "Nucleus",
        issue_number: parseInt(issueNum)
    }
    let name = "Unknown";
    const components: InteractionEditReplyOptions["components"] = [];
    switch(interaction.customId) {
        case "accept:Suggestion": {
            name = "Accepted";
            await interaction.deferUpdate();
            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion accepted by " + interaction.user.tag});
            components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
                new ButtonBuilder().setCustomId("close:Suggestion").setLabel("Close").setStyle(ButtonStyle.Secondary),
                new ButtonBuilder().setCustomId("implemented:Suggestion").setLabel("Implemented").setStyle(ButtonStyle.Secondary)
            ))
            break;
        }
        case "deny:Suggestion": {
            name = "Denied";
            const reason = await getReason(interaction, "Reason for denial");
            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion denied by " + interaction.user.tag + " for reason:\n>" + reason});
            await client.GitHub.rest.issues.update({...issue, state: "closed", state_reason: "not_planned"});
            // await client.GitHub.rest.issues.lock({...issue, lock_reason: "resolved"})
            components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
                new ButtonBuilder().setCustomId("lock:Suggestion").setLabel("Lock").setStyle(ButtonStyle.Danger)
            ))
            break;
        }
        case "close:Suggestion": {
            name = "Closed";
            const reason = await getReason(interaction, "Reason for closing");
            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion closed by " + interaction.user.tag + " for reason:\n>" + reason});
            await client.GitHub.rest.issues.update({...issue, state: "closed"});
            // await client.GitHub.rest.issues.lock({...issue})
            components.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
                new ButtonBuilder().setCustomId("lock:Suggestion").setLabel("Lock").setStyle(ButtonStyle.Danger)
            ))
            break;
        }
        case "implement:Suggestion": {
            name = "Implemented";
            await interaction.deferUpdate();
            await client.GitHub.rest.issues.createComment({...issue, body: "Suggestion implemented"});
            await client.GitHub.rest.issues.update({...issue, state: "closed", state_reason: "completed"});
            await client.GitHub.rest.issues.lock({...issue, lock_reason: "resolved"})
            break;
        }
        case "lock:Suggestion": {
            name = "Locked";
            await interaction.deferUpdate();
            await client.GitHub.rest.issues.lock({...issue});
            break;
        }
        case "spam:Suggestion": {
            name = "Marked as Spam";
            await interaction.deferUpdate();
            await client.GitHub.rest.issues.update({...issue, state: "closed", state_reason: "not_planned"});
            await client.GitHub.rest.issues.lock({...issue, lock_reason: "spam"})
            break;
        }
    }

    const newcolor = accept ? "Success" : "Danger";
    const newEmoji = accept ? "ICONS.ADD" : "ICONS.OPP.ADD";

    const newEmbed = new EmojiEmbed()
        .setEmoji(newEmoji)
        .setTitle(embed!.title!.replace(/.+> /, ""))
        .setDescription(embed!.description!)
        .setFields({
            name: name + " by",
            value: interaction.user.tag,
        })
        .setStatus(newcolor)
        .setFooter(embed!.footer);

    await interaction.editReply({
        embeds: [newEmbed],
        components: components
    });
}

export async function callback(_client: NucleusClient, interaction: Interaction) {
    await interactionCreate(interaction);
}
