Search code examples
javadiscord-jda

Editing ephemeral messages in discord jda


I am sending an ephemeral message with an EntitySelectMenu. When the user selects the items in this menu, I need to change the content of the ephemeral message to some text like "abc". I tried doing it like this:

In EntitySelectInterection

event.deferEdit().queue(); // defer editing to make sure menu is disabled
event.getHook().retrieveOriginal().queue(message -> { // get original message
    String content = "abc";
    message.editMessage(content).queue(); // update message content
});

But this edits the text of the message to which the ephemeral is attached, but not the ephemeral itself. Would be grateful for any help.


Solution

  • You have to edit messages using getHook(). For instance:

    event.deferEdit().queue();
    event.getHook().editOriginal("abc").queue();
    

    Using the message instead, will use a bot endpoint rather than an interaction endpoint.