Why is Member null when using Guild.getMemberById(...)? #1599
-
jda.getGuildById(...).getMemberById(...) I get null, but on the Server in my Guild the Member exists. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
When using methods such as When using There are several options that you can do instead:
Please read this page for more info: |
Beta Was this translation helpful? Give feedback.
When using methods such as
getMember()
orgetMemberById(String)
there's a possibility that the returned Member is null.There can be many reasons, but most of the time the cause is that a Member isn't cached (yet).
When using
createLight(String)
orcreateDefault(String)
for building a JDA/ShardManager instance JDA will disable Member Caching and Member Chunking.This has the side-effect that JDA doesn't "know" a member yet and therefore returns null since a Member is nullable.
There are several options that you can do instead:
getAuthor()
instead as this returns a User object which won't be null.re…