premiumSubscriptionCount is NaN

what could be the cause of this?
5 Replies
d.js toolkit
d.js toolkit7mo 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!
treble/luna
treble/luna7mo ago
* Show your code!
TehPig
TehPigOP7mo ago
I am trying to emit the guildMemberUpdate event to test a function, but if I log member and newMember the premiumSubscriptionCount value is for both null
const member = msg.guild.members.cache.get("298432708269441034")
const newMember = member;
newMember.guild.premiumSubscriptionCount++;
bot.emit("guildMemberUpdate", member, newMember)
const member = msg.guild.members.cache.get("298432708269441034")
const newMember = member;
newMember.guild.premiumSubscriptionCount++;
bot.emit("guildMemberUpdate", member, newMember)
To note, the server has currently 2 boosts i manipulate the event because i do not own a lot of accounts in order to test the function properly. if i do not clone the object how should i do it then so by using this code the boost count should be incremented by 1, right? there is something that I have not completely understood from the results I get both oldMember and newMember are set to 3 boosts
const member = msg.guild.members.cache.get("298432708269441034")
const newMember = member._clone();
newMember.guild.premiumSubscriptionCount++;
bot.emit("guildMemberUpdate", member, newMember)
const member = msg.guild.members.cache.get("298432708269441034")
const newMember = member._clone();
newMember.guild.premiumSubscriptionCount++;
bot.emit("guildMemberUpdate", member, newMember)
so what you're saying is that this boost check cant be manually triggered. but it will work premiumSince updates only for the first boost though, right?
d.js docs
d.js docs7mo 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.
}
});
TehPig
TehPigOP7mo ago
so that's why listening to the system messages is the only way then. just sending a cusstom message basically, nothing too fancy would be nice for it to work for every boost message but if it's not possible i suppose having one is better than nothing the bot is for a single server which I own which should be fine

Did you find this page helpful?