繁体   English   中英

如何使用 Java 编辑 Discord 机器人(我自己)发送的消息?

[英]How can I edit a message send by Discord bot (Myself) with Java?

我看到许多 discord 机器人发送消息,然后他们通过一个按钮左右编辑相同的消息,我想知道如何编辑我的 discord 机器人发送的消息?

我想要的是机器人将发送一个嵌入,然后在按下按钮时,嵌入消息将被编辑为其他内容。 有什么帮助吗? 我使用 Java jda。

可能是这样:

public void onButtonInteraction(ButtonInteractionEvent event){

    if (event.getButton.getId.equals("example_id")) // getting the button
        {
        event.deferEdit.queue();  //acknowledging the interaction

        EmbedBuilder new_Embed = new EmbedBuilder()
               .setTitle("exampleTitle")
               .setDescription("exampleDescription");  //building the Embed

        event.getMessage.editMessageEmbed(new_Embed.build).queue(); // editing the message
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM