Reputation: 77
I have been trying to use the following code but somehow it doesn't work at all. The idea is to have a server log on console for users coming online and going offline.
bot.on("Presence", usr => {
if (usr.status == 'offline'){
console.log(`${usr.username} is offline`);
} else if (usr.status == 'online') {
console.log(`${usr.username} is online`);
}
});
Upvotes: 1
Views: 3611
Reputation: 3424
First of all, I know that is JS but you really should put the name of the programming language you're coding in and add it as a tag otherwise nobody will find your question. Secondly if you check the docs, the name of the event is presenceUpdate
.
bot.on("presenceUpdate", (oldMember, newMember) => {
if(oldMember.presence.status !== newMember.presence.status){
console.log(`${newMember.user.username} is now ${newMember.presence.status}`);
}
});
Upvotes: 2