package fr.Skydust.JdrBot.menu;

import fr.Skydust.JdrBot.utils.UnicodeEmotes;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;

import java.awt.*;

public class Menu {
    public String thumbnail;
    public String name;
    public String title;

    public String[] items;

    public Menu(String name, String title, String thumbnail, String[] items) {
        this.name = name;
        this.title = title;
        this.thumbnail = thumbnail;
        this.items = items;
    }

    public void onButtonClicked(Member member, Message msg, int itemId) { }

    /** Builds the menu message */
    public MessageCreateData makeMessage() {
        StringBuilder str = new StringBuilder();

        int i = 0;
        for (String s : items) {
            str.append(UnicodeEmotes.CharsUnicodeArray[i] +" "+ s +"\n");
            i++;
        }

        return new MessageCreateBuilder()
                .addContent(name)
                .setEmbeds(
                        new EmbedBuilder()
                                .setThumbnail(thumbnail)
                                .setTitle(title,null)
                                .setColor(Color.green)
                                .setDescription("\n"+ str)
                                .build())
                .build();
    }
}
