Tracking user boosts and unboosts

I am trying to find out when a user starts boosting and stops boosting however. I seem to be catching all the times a user boosts but only a couple of the times a user stops boosting. I thought it was something to do with cache or what not but I am completely clueless. I have attached 2 screenshots, one of my bot clearly not logging a user has stopped boosting and one of mee6 picking it up. I dont need to know how many times they've boosted or what ever, just whether they have the server booster role and if they loose it. My code is below
// Handle Discord Boosting
client.on(Events.GuildMemberUpdate, (oldMember, newMember) => {
// Check if the role was added
if (!oldMember.roles.cache.has(roles.BOOSTER) && newMember.roles.cache.has(roles.BOOSTER)) {
// A new booster
doBoostUpdate(newMember.user.id, true);
logger.info(`${newMember.id} is now boosting`);
}

// Check if the role was removed
if (oldMember.roles.cache.has(roles.BOOSTER) && !newMember.roles.cache.has(roles.BOOSTER)) {
// No longer a booster
doBoostUpdate(newMember.user.id, false);
logger.info(`${newMember.id} is no longer boosting`);
}
});
// Handle Discord Boosting
client.on(Events.GuildMemberUpdate, (oldMember, newMember) => {
// Check if the role was added
if (!oldMember.roles.cache.has(roles.BOOSTER) && newMember.roles.cache.has(roles.BOOSTER)) {
// A new booster
doBoostUpdate(newMember.user.id, true);
logger.info(`${newMember.id} is now boosting`);
}

// Check if the role was removed
if (oldMember.roles.cache.has(roles.BOOSTER) && !newMember.roles.cache.has(roles.BOOSTER)) {
// No longer a booster
doBoostUpdate(newMember.user.id, false);
logger.info(`${newMember.id} is no longer boosting`);
}
});
No description
No description
6 Replies
d.js toolkit
d.js toolkit4w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
james090500
james0905004w ago
DiscordJS version - discord.js@14.15.3 Node version- v22.4.1
treble/luna
treble/luna4w ago
oldMember can be partial In which case the event womt emit (unless you have enabled partials) and even if you enable partials the only thing that would be guaranteed to be present is the id
james090500
james0905004w ago
So is there any good way of doing this? To check when a member loses a role or gains a certain role
treble/luna
treble/luna4w ago
You'd have to store their roles in order for this to work
james090500
james0905003w ago
Ok, ive decided to just check the role every hour, get a list of ID;s and remove any from the system that aren;t in there
Want results from more Discord servers?
Add your server