From eb93362d1673d9cb73bf0572ed9e0e1ea9771bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Wed, 21 Dec 2022 04:37:32 +0100 Subject: [PATCH] Add emojis to trivia buttons --- .../beatrice/hidekobot/runnables/TriviaTask.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/wtf/beatrice/hidekobot/runnables/TriviaTask.java b/src/main/java/wtf/beatrice/hidekobot/runnables/TriviaTask.java index 54b1fc6..cf7ceb8 100644 --- a/src/main/java/wtf/beatrice/hidekobot/runnables/TriviaTask.java +++ b/src/main/java/wtf/beatrice/hidekobot/runnables/TriviaTask.java @@ -4,6 +4,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.interactions.components.buttons.Button; import org.json.JSONObject; import wtf.beatrice.hidekobot.Cache; @@ -12,6 +13,7 @@ import wtf.beatrice.hidekobot.util.CommandUtil; import wtf.beatrice.hidekobot.util.TriviaUtil; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledFuture; @@ -86,6 +88,20 @@ public class TriviaTask implements Runnable Collections.shuffle(answerButtons); + List buttonEmojis = Arrays.asList("\uD83D\uDD34", "\uD83D\uDD35", + "\uD83D\uDFE2", "\uD83D\uDFE1", "\uD83D\uDFE4", "\uD83D\uDFE3", "\uD83D\uDFE0"); + + // add emojis to buttons + for(int emojiPos = 0; emojiPos < buttonEmojis.size(); emojiPos++) + { + if(emojiPos == answerButtons.size()) break; + + String emoji = buttonEmojis.get(emojiPos); + Button button = answerButtons.get(emojiPos); + + answerButtons.set(emojiPos, button.withEmoji(Emoji.fromUnicode(emoji))); + } + EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setColor(Cache.getBotColor());