I have written the following methods and they both are not working. Anyone know why and how to fix it?
PS: The bot has admin perms.
To quote the JDA Wiki:
There are many reasons why your event listener might not be executed but here are the most common issues:
- You are using the wrong login token?
If the token is for another bot which doesn't have access to the desired guilds then the event listener code cannot run.- Your bot is not actually in the guild?
Make sure your bot is online and has access to the resource you are trying to interact with.- You never registered your listener?
Usejda.addEventListener(new MyListener())
on either theJDABuilder
orJDA
instance- You did not override the correct method?
Use@Override
and see if it fails. Your method has to use the correct name and parameter list defined inListenerAdapter
.- You don't actually extend
EventListener
orListenerAdapter
.
Your class should either useextends ListenerAdapter
orimplements EventListener
.- You are missing a required
GatewayIntent
for this event.
Make sure that youenableIntents(...)
on theJDABuilder
to allow the events to be received.- The event has other requirements that might not be satisfied such as the cache not being enabled.
Please check the requirements on the event documentation.If none of the above apply to you then you might have an issue in your listener's code, at that point you should use a debugger.
For clarification:
You can enable the GUILD_MEMBERS
intent by doing builder.enableIntents(GatewayIntent.GUILD_MEMBERS)
on JDABuilder
.
For example:
JDABuilder builder = JDABuilder.createDefault(token);
builder.enableIntents(GatewayIntent.GUILD_MEMBERS);
builder.addEventListeners(myListener);
JDA jda = builder.build();