'Java JDA Bot How to check if message is written by specific User

I want to make a command which some users are allowed to use, but somehow my checks do not work

 Member member = event.getGuild().retrieveMemberById("id").complete();

        if(event.getAuthor().isBot()) return;
        if(event.getMember() == member) { ... }

I also tried

Member member = event.getMemerById("id"); 

but non of this worked can anyone help me?



Solution 1:[1]

You can just check the id of the author directly:

if (event.getAuthor().getId().equals("id")) {
  ...
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Minn