server boost event and boost revoke event

is there a way to detect when a server gets boosted and when the boost gets revoked?
13 Replies
d.js toolkit
d.js toolkit4mo 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! - Marked as resolved by staff
d.js docs
d.js docs4mo ago
The Discord API does not provide a dedicated event for guild boosts, but you can check for it in the guildMemberUpdate event:
client.on("guildMemberUpdate", (oldMember, newMember) => {
// Check if the member wasn't boosting before, but is now.
if (!oldMember.premiumSince && newMember.premiumSince) {
// Member started boosting.
}
});
client.on("guildMemberUpdate", (oldMember, newMember) => {
// Check if the member wasn't boosting before, but is now.
if (!oldMember.premiumSince && newMember.premiumSince) {
// Member started boosting.
}
});
can
can4mo ago
this only works in a scenario where the user has not boosted before and is boosting for the first time it is not possible to see when a user cancels their boost or boost server (for example if the user is already boosting the server and boost again, this if will return false) at least, Discord currently does not send an event to the bots when a user boosts a server or cancels a boost. I think this kind of approach is not a complete solution
dito
ditoOP4mo ago
i dont care for it to detect the second boost i just need to detect when a person boosts and unboosts maybe i can use the role for that? like check role updates
can
can4mo ago
then the snippet above should work for you
dito
ditoOP4mo ago
yeah but i need it to detect when they revoke the boost
if (oldMember.premiumSince && !newMember.premiumSince) {

}
if (oldMember.premiumSince && !newMember.premiumSince) {

}
will this work for that?
can
can4mo ago
it is not possible to see when a user cancels their boost
dito
ditoOP4mo ago
i mean is it possible by checking their roles?
can
can4mo ago
yes detecting 0 boost -> 1 boost & 1 boost -> 0 boost is possible by checking roles but revoking is not detectable
dito
ditoOP4mo ago
how is it not possible with this though? wdym revoking
can
can4mo ago
like when someone has 2 boost & cancels 1 boost, you cant detect, because the user will still have a role
dito
ditoOP4mo ago
i dont care about the second boost. i only care if a person is boosting or not doesnt matter the quantity
can
can4mo ago
..
Want results from more Discord servers?
Add your server