Thatsmycarnow12
Thatsmycarnow12

Reputation: 1

How can I kick a certain user after someone typed a specific message

bot.on ('message', message =>{

   if (message.content === ("test")) {

    message.guild.members.get("their id").kick(); //ive seen this online but i
                                                  //dont know how to set up this guild thing

So when someone types test a specific user should be kicked

Upvotes: 0

Views: 47

Answers (2)

ThatNameIsNowMine
ThatNameIsNowMine

Reputation: 11

Giuliopime I don't know why I can't comment anymore. Just wanted to say thanks for your help it works!

Upvotes: 1

Giuliopime
Giuliopime

Reputation: 1197

To kick a specific member you need to get him from the guild.members.cache.

So:

if(message.content === 'test' && message.channel.type === 'text'){
   message.guild.members.cache.get('ID of the member to kick').kick();
}

The message.channel.type === 'text' is there to prevent the bot from breaking when it receives the 'test' message in DMs, because if it receives it in DMs, it's not able to get the message.guild. Hope this helps.

Upvotes: 0

Related Questions