Kārlis Kazāks
Kārlis Kazāks

Reputation: 193

How to check if client was kicked?

I need to know when my client/bot was kicked from a server. I have looked at Grepper discord.js guide and countless more but I couldn't find anything.

I'm really sure that there is a client.on event for this. Like:

client.on('kicked', (guild) => {
    console.log(`${client.user.username} was kicked from ${guild.name}`);
});

How can I check when the bot was kicked from a server and just console.log it?

Upvotes: 0

Views: 562

Answers (2)

Jakye
Jakye

Reputation: 6625

You can use the guildDelete event which is emitted whenever the client is kicked from the guild or the guild is deleted.


client.on('guildDelete', guild => {
    console.log(`${client.user.username} was kicked from ${guild.name}.`);
});

Upvotes: 3

Aldirrix
Aldirrix

Reputation: 119

from this cheatsheet

client.on("guildMemberRemove", function(member){
  console.log(`a member leaves a guild, or is kicked: ${member.tag}`);
});

Upvotes: 0

Related Questions