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));
}
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);
}
}
Aggregations