javaeventsdiscord-jda

How to get username by message id


I am facing a problem that I can't find out the username from the id of his message, I have tried many ways but I still can't do it, please help me.

I have no idea how to do this (second day learning JDA - Java Discord API)


Solution

  • U need the TextChannel or PrivateChannel too...

    channel.retrieveMessageById(id).queue((message) -> {
         User u = message.getAuthor();
    
         //only in TextChannels on Guilds
         Member m = message.getMember();
    }
    

    I hope I could help you :)