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:
and
15 Replies
- 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!Please help 😭
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 doOk, I got cache customization working, limiting Users
but now presence Intent seems broken
and the bot is much lighter now, 3x
what is your use for presence event first of all
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
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
yeah you can disable the cache, because the cache for that event is only needed for their old presence anyways
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..
😭
depression
I ended up offering the feature I need presence for only for custom branding bots which are just in a single server
its fine
its life
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.
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
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.