Search in sources :

Example 1 with Nominate

use of de.tectoast.emolga.buttons.buttonsaves.Nominate in project Emolga by TecToast.

the class NominateCommand method process.

@Override
public void process(PrivateMessageReceivedEvent e) {
    JSONObject nds = getEmolgaJSON().getJSONObject("drafts").getJSONObject("NDS");
    JSONObject nom = nds.getJSONObject("nominations");
    int currentDay = nom.getInt("currentDay");
    if (!nom.has(currentDay))
        nom.put(currentDay, new JSONObject());
    if (nom.getJSONObject(String.valueOf(currentDay)).has(e.getAuthor().getId())) {
        e.getChannel().sendMessage("Du hast für diesen Spieltag dein Team bereits nominiert!").queue();
        return;
    }
    JSONArray arr = nds.getJSONObject("picks").getJSONArray(e.getAuthor().getId());
    List<JSONObject> list = arr.toJSONList();
    list.sort(tiercomparator);
    List<String> b = list.stream().map(o -> o.getString("name")).collect(Collectors.toList());
    Nominate n = new Nominate(list);
    e.getChannel().sendMessageEmbeds(new EmbedBuilder().setTitle("Nominierungen").setColor(Color.CYAN).setDescription(n.generateDescription()).build()).setActionRows(addAndReturn(getActionRows(b, s -> Button.primary("nominate;" + s, s)), ActionRow.of(Button.success("nominate;FINISH", Emoji.fromUnicode("✅"))))).queue(m -> nominateButtons.put(m.getIdLong(), n));
}
Also used : JSONObject(org.jsolf.JSONObject) Arrays(java.util.Arrays) PrivateMessageReceivedEvent(net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Emoji(net.dv8tion.jda.api.entities.Emoji) PrivateCommand(de.tectoast.emolga.commands.PrivateCommand) Collectors(java.util.stream.Collectors) java.awt(java.awt) Command(de.tectoast.emolga.commands.Command) List(java.util.List) Nominate(de.tectoast.emolga.buttons.buttonsaves.Nominate) JSONArray(org.jsolf.JSONArray) Button(net.dv8tion.jda.api.interactions.components.Button) ActionRow(net.dv8tion.jda.api.interactions.components.ActionRow) Comparator(java.util.Comparator) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) JSONObject(org.jsolf.JSONObject) JSONArray(org.jsolf.JSONArray) Nominate(de.tectoast.emolga.buttons.buttonsaves.Nominate)

Example 2 with Nominate

use of de.tectoast.emolga.buttons.buttonsaves.Nominate in project Emolga by TecToast.

the class NominateButton method process.

@Override
public void process(ButtonClickEvent e, String name) {
    Nominate n = nominateButtons.get(e.getMessageIdLong());
    if (n == null) {
        e.reply("Diese Nachricht ist veraltet! Nutze erneut `!nominate`!").queue();
        return;
    }
    if (e.getComponent().getStyle() == ButtonStyle.PRIMARY) {
        n.unnominate(name);
        n.render(e);
    } else if (e.getComponent().getStyle() == ButtonStyle.SECONDARY) {
        n.nominate(name);
        n.render(e);
    } else if (e.getComponent().getStyle() == ButtonStyle.SUCCESS) {
        n.finish(e, name.equals("FINISHNOW"));
    } else if (e.getComponent().getStyle() == ButtonStyle.DANGER) {
        n.render(e);
    }
}
Also used : Nominate(de.tectoast.emolga.buttons.buttonsaves.Nominate)

Aggregations

Nominate (de.tectoast.emolga.buttons.buttonsaves.Nominate)2 Command (de.tectoast.emolga.commands.Command)1 PrivateCommand (de.tectoast.emolga.commands.PrivateCommand)1 java.awt (java.awt)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)1 Emoji (net.dv8tion.jda.api.entities.Emoji)1 PrivateMessageReceivedEvent (net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent)1 ActionRow (net.dv8tion.jda.api.interactions.components.ActionRow)1 Button (net.dv8tion.jda.api.interactions.components.Button)1 JSONArray (org.jsolf.JSONArray)1 JSONObject (org.jsolf.JSONObject)1