pietro bacigalupi
pietro bacigalupi

Reputation: 41

Get Mentioned User of a Embed- Discord API (JDA)

How can I get a user mentioned in an embed? I tried something like this but it always returns null.

        final String[] nome = {null};
        channel.retrieveMessageById(reaction.getMessageId()).queue(message -> {
            nome[0] = (message.getMentionedMembers().get(0).getEffectiveName());
        });

Upvotes: 0

Views: 541

Answers (1)

Raffon
Raffon

Reputation: 133

Your message is an embed so you can’t use it as a string. You need to get the embed from your message like this:

EmbedMessage eb = message.getEmbeds().get(0);

And then you can loop through fields and find the field you are looking for:

for (MessageEmbed.Field field : eb.getFields()) {
    System.out.println(field.getValue());
}

Upvotes: 1

Related Questions