work-around d.js bug

This commit is contained in:
Lamp 2018-08-11 21:40:45 -07:00
parent 61c9df599b
commit 2b8f616efe
No known key found for this signature in database
GPG Key ID: 0F1F8704BEDE369E
1 changed files with 111 additions and 106 deletions

View File

@ -85,13 +85,18 @@ colorRoles.pruneOrphanRoles = async function() { // delete all color roles that
// event listeners
dClient.on('presenceUpdate', async (oldMember, newMember) => { // update color role on presence update // emitted also on member join
if (!oldMember || !newMember) return; //TODO debug
dClient.on('presenceUpdate', async (oldMember, newMember) => { // update color role on presence update // emitted also on member join (iirc)
/* if (!oldMember || !newMember) return;
if (!oldMember.presence || !newMember.presence) return;
// TODO discord.js bug?
// oldMember.presence & newMember.presence are undefined
if (oldMember.presence.status != newMember.presence.status) {
await colorRoles.update(newMember);
}
}*/
await colorRoles.update(newMember.user.presence.status);
});
dClient.on('guildMemberRemove', async member => { // update (delete) color role on member leave
await colorRoles.update(member);
});