leguan
leguan

Reputation: 98

I have a Problem with Discord4Js MemberJoinEvent

I just started programming a new Discord bot for myself to see what I am able to create. Currently, I'm working on an Autorole feature but I just don't get why the Bot doesn't get triggered by a MemberJoinEvent. Here is my code:

gateway.getEventDispatcher().on(MemberJoinEvent.class).subscribe(memberJoinEvent -> {
       final Member member = memberJoinEvent.getMember();            
       System.out.println(member.toString());
});

Upvotes: 1

Views: 335

Answers (2)

Patrick Brielmayer
Patrick Brielmayer

Reputation: 272

In addition to leguans answer, I also had to request the gateway intents as well!

GatewayDiscordClient gatewayDiscordClient() {
    return discordClient()
        .gateway()
        .setEnabledIntents(IntentSet.all())
        .login()
        .block();
}

https://docs.discord4j.com/migrating-from-v3-1-to-v3-2/#gateway-intents

Upvotes: 0

leguan
leguan

Reputation: 98

I found the problem! I didnt know that discord changed something in their developer portal. Also I used my old project so I didnt notice it. You have to manualy enable it in the developer portal, that the bot can access member information. A screenshot of the location to enable the gateway feature

Upvotes: 1

Related Questions