PresenceUpdate usage

How can I reduce the memory demand of presenceUpdate events, I dont need them per guild, I just need the presence and the id of the user, simply as that. My use case is to save music people listen to and make graphs on that. But my memory gets too high because of this event. I already tried:
GuildMemberManager: {
maxSize: 1,
keepOverLimit: (member) => member.id === member.client.user.id,
},
GuildMemberManager: {
maxSize: 1,
keepOverLimit: (member) => member.id === member.client.user.id,
},
and
PresenceManager: 0,
PresenceManager: 0,
15 Replies
d.js toolkit
d.js toolkit•5mo 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!
Cauã Gabriel
Cauã Gabriel•5mo ago
Please help 😭
duck
duck•5mo ago
tbh this is more something you'd need to deal with than prevent cache customizations wouldn't prevent discord from sending the event to your bot, so your Client would still be receiving and handling these events per guild anyways therefore resource usage should be expected to be high with the GuildPresences intent enabled if you've already tried cache customization, that's about as much as you can do
Cauã Gabriel
Cauã Gabriel•5mo ago
Ok, I got cache customization working, limiting Users but now presence Intent seems broken and the bot is much lighter now, 3x
Digital
Digital•5mo ago
what is your use for presence event first of all
Mark
Mark•5mo ago
It was explained in their post If the cache can be limited and a partial utilized just to get the incoming/new presence data, that might be what works best
Digital
Digital•5mo ago
ah music from presence i thought smth else why do you even need cache then if you just save what someone listens in db afaik disabling cache still makes the event work
Jaymart
Jaymart•5mo ago
yeah you can disable the cache, because the cache for that event is only needed for their old presence anyways
Jonah
Jonah•5mo ago
There is nothing you can do about as you only get the presence of a user when its in cache. Doing some cache option will lower the ram usage a bit but wont solve your problem as there is no good solution. Another downside is that your CPU usage is significantly higher as you receive tons of events from discord. I speak out of painful experience..
Cauã Gabriel
Cauã Gabriel•5mo ago
😭 depression
Jonah
Jonah•5mo ago
I ended up offering the feature I need presence for only for custom branding bots which are just in a single server
Cauã Gabriel
Cauã Gabriel•5mo ago
its fine its life
Jaymart
Jaymart•5mo ago
so i found out the hard way. this is just a lib thing, you don't need the member cached to receive the event. depending on your use case you can actually get away without with alot.
Digital
Digital•5mo ago
doesn't really help with tons of events from discord, i dont get why its been made to be per server instead of just one per user you get x events because you share x servers with user instead of 1
Jaymart
Jaymart•5mo ago
in this persons use case yes it does, he does not need member cache at all. all he is doing is saving their music, discord sends this event regardless if the member is in the cache. some libs for some reason, make it so if that member isn't cached you don't get the event. all the cache does is allow you to access the data sent from a previous update directly before the new one is sent.
Want results from more Discord servers?
Add your server