package com.avairebot.orion.factories;

import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.MessageChannel;
import net.dv8tion.jda.core.requests.RestAction;

import java.awt.*;

import static com.avairebot.orion.factories.MessageFactory.MessageType.*;

public class MessageFactory {

    public static RestAction<Message> makeError(Message jdaMessage, String message, Object... args) {
        return makeEmbeddedMessage(jdaMessage, ERROR, message, args);
    }

    public static RestAction<Message> makeWarning(Message jdaMessage, String message, Object... args) {
        return makeEmbeddedMessage(jdaMessage, WARNING, message, args);
    }

    public static RestAction<Message> makeSuccess(Message jdaMessage, String message, Object... args) {
        return makeEmbeddedMessage(jdaMessage, SUCCESS, message, args);
    }

    public static RestAction<Message> makeInfo(Message jdaMessage, String message, Object... args) {
        return makeEmbeddedMessage(jdaMessage, INFO, message, args);
    }

    public static RestAction<Message> makeEmbeddedMessage(Message jdaMessage, MessageType type, String message, Object... args) {
        return makeEmbeddedMessage(jdaMessage.getChannel(), type.getColor(), prepareMessage(jdaMessage, message, args));
    }

    public static RestAction<Message> makeEmbeddedMessage(MessageChannel channel, Color color, String message) {
        return channel.sendMessage(new EmbedBuilder().setColor(color).setDescription(message).build());
    }

    private static String prepareMessage(Message jdaMessage, String message, Object... args) {
        return String.format(message, args);
    }

    public enum MessageType {
        ERROR("#EF5350"),
        WARNING("#FAA61A"),
        SUCCESS("#43B581"),
        INFO("#3A71C1");

        private final String color;

        MessageType(String color) {
            this.color = color;
        }

        public Color getColor() {
            return Color.decode(this.color);
        }
    }
}

@@ -174,16 +174,73 @@
 hannel;%0A
+import net.dv8tion.jda.core.entities.MessageEmbed.Field;%0A
 import n
@@ -299,16 +299,41 @@
 a.awt.*;
+%0Aimport java.util.Arrays;
 %0A%0Aimport
@@ -1632,24 +1632,339 @@
 ());%0A    %7D%0A%0A
+    public static RestAction%3CMessage%3E makeEmbeddedMessage(MessageChannel channel, MessageType type, Field... fields) %7B%0A        EmbedBuilder embed = new EmbedBuilder().setColor(type.getColor());%0A        Arrays.stream(fields).forEachOrdered(embed::addField);%0A        return channel.sendMessage(embed.build());%0A    %7D%0A%0A
     private 

Create message factory method with support for fields