Replies: 1 comment 1 reply
-
I'm fully against this. While at the moment this seems to be sensible since the data should theoretically not vary based on guild this could change at any point if discord decides to do so, as per API specification presences are intrinsically bound to specific guilds. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
Right now, presences are sent for each GuildMember via
PRESENCE_UPDATE
andGUILD_CREATE
events. The library handle them and cache them, very correct behaviour.Unfortunately having one presence for each GuildMember makes the bot use too much memory, and if memory usage is a big requirement for you (example: having a low-sized RAM machine) it quickly become a serious problem.
Also, the
presence
getter of theUser
class take the first GuildMember presence associated to the member it finds by iterating over guilds ; since many developers use this getter they do not even get the current guild's presence which make the necessity of having GuildMember presences useless.This could save RAM by having one presence per User and no longer one per GuildMember. I have also suggested an endpoint to fetch someone's presence on Discord API repo so we may just don't need to cache presences we don't need (and save a lot of RAM).
Describe the ideal solution
Have a
ClientOptions
property likeuniquePresences
which would be a boolean (default tofalse
to respect Discord API scheme).true
: store all presences inClient#presences
and leavepresences
of allGuild
instances empty.false
: leaveClient#presences
empty (or not ?) and usepresences
of allGuild
instancesDescribe alternatives you've considered
If forking the repository so we can edit the code to make it store everything
Client#presences
, then yes. Otherwise, no.Additional context
Before sweeping presences (~ 30 minutes of uptime w/ around 850 guilds and ~ 110k users):
After:
Longer you'll leave the bot online bigger the mem-delta will be.
Beta Was this translation helpful? Give feedback.
All reactions