Discord JDA Emote in EmbedBuilder

Im currently working on a discord bot and Im trying to display a custom server emote inside the embed message, it should appear in "insert emote_icon" but Im not able to get it done. Is it even possible and if yes, how?

if (member.hasPermission(Permission.ADMINISTRATOR)) {
            if (args.length == 2) {
                if (args[1].contains("test")) {
                    try {

                        Guild guild = tChannel.getGuild();
                        EmbedBuilder embedBuilder = new EmbedBuilder();

                        embedBuilder.setColor(Color.GRAY);
                        embedBuilder.setAuthor("~Jokers Rival | Rufus");
                        embedBuilder.setTitle("----= **Title** =----");
                        embedBuilder.setDescription("Test title");

                        embedBuilder.addField("test1", "<insert emote_icon>", true);

                        tChannel.sendMessage(embedBuilder.build()).queue();
                        return;

                    } catch (Exception e) {}
                }
            }
            return;
        }
``

Upvotes: 0

Views: 3266

Answers (1)

Minn
Minn

Reputation: 6131

You can put custom emotes in text components by using the correct message format. To get this format you can simply post the emote in a channel and put a backslash \ before it:

enter image description here enter image description here

Then you can use that in your code:

embedBuilder.addField("test1", "<:vim:414776062380343296>", true);

The bot has to be in the guild where this emote is from and it must have access rights. Twitch subscriber emotes are only available to twitch subscribers etc.

Upvotes: 2

Related Questions