Ad

How To Kick On Specific Message

- 1 answer

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');
  }
});
Ad

Answer

.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');
  }
});
Ad
source: stackoverflow.com
Ad