簡體   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