Reputation: 3
I'm trying to auto-kick people with my discord bot when they send an invite link, but message.author.kick()
doesn't seem to work. I've also tried other variations of it, like member.kick()
.
This is my code so far:
client.on('message', message => {
if (message.content.includes('discord.gg/')) {
message.channel.send('Nope');
message.delete(3000);
message.author.kick('posting links');
}
});
Upvotes: 0
Views: 874
Reputation: 2980
.author
gives a User
object that you can't kick. You have to kick a GuildMember
: you can obtain the author's member object by using message.member
.
Here is the correction of your code:
client.on('message', message => {
if (message.content.includes('discord.gg/')) {
message.channel.send('Nope');
message.delete(3000);
message.member.kick('posting links');
}
});
Upvotes: 2