How to add reaction to an embed message JDA

前端 未结 2 2036
南笙
南笙 2021-01-28 03:11

I\'m trying to send and embed message when I do the command ~verify and then it sends an embed message and I cant find how to add to there a reaction.

I did already the

相关标签:
2条回答
  • 2021-01-28 03:36

    You can access the sent message in the callback for queue() and add reactions there:

    channel.sendMessage(embed).queue(message -> message.addReaction(reaction).queue());
    

    To add multiple questions you can use a multiline lambda:

    channel.sendMessage(embed).queue(message -> {
      message.addReaction(reaction1).queue();
      message.addReaction(reaction2).queue();
      message.addReaction(reaction3).queue();
    });
    

    Also there is no reason to clear the EmbedBuilder because it won't be used again in your code. Builders are usually not resources that need to be closed/cleared unless you use them again and don't want the previous settings.

    0 讨论(0)
  • 2021-01-28 03:40

    I understood how to do it. Just need to add this line

     e.getChannel().sendMessage(embedBuilder.build()).complete().addReaction("✔").queue();
    
    0 讨论(0)
提交回复
热议问题