daniel
daniel

Reputation: 1

discord.js How to ban someone when they join if they match a specific ID

I am trying to check to see if a user is a specific user when they join my discord server and then ban them if they are. I am pretty new to this and this code is not working. any help?

client.on("guildMemberAdd", (member) => {
    if (member.id === "401539231828148224") {
        member.ban;
    }
});

Upvotes: 0

Views: 479

Answers (1)

Jakye
Jakye

Reputation: 6625

GuildMember#ban is a method, not a property. You'll have to use parentheses. (())

client.on("guildMemberAdd", (member) => {
    if (member.id === "401539231828148224") {
        member.ban({ reason: "Reason for the ban." });
    }
});

Note that you need to activate the Server Members Intent in your application's Bot tab.

Upvotes: 3

Related Questions