Feature: Add member object to message events + better intent cache handling
Created by: Neuheit
Summary
Implements support for the member object in member events and also consolidated member updating into one method that has better intent cache handling.
Details
Previously the member object returned from the D#+ message events would be incomplete (such as missing roles) if the GuildPresences
intent was disabled. This PR fixes that by making the client take advantage of the fresh member that was received. Additionally, I reworked member cache handling in the UpdateUser
method to update the guild's member cache depending on what intents are specified. It checks through the following states:
All privileged intents
: Attempts to cache the member if the guild is large, otherwise skips over the caching process.
Only GuildMembers
: Attempts to add the member to the guild's member cache since it may not be present, since that member can be updated via Guild Member Add/Update/Removed
Only GuildPresences:
Attempts to update the member in the guild's cache since it will be present, but won't be updated via guild member events.
No privileged intents
: This depends on a new value in the DiscordConfiguration
. If set to true, the client will attempt to add/update the member object for that guild. If set to false, member caching will be ignored.
This should greatly help users that don't enable all privileged intents, and should be a large benefit for CommandsNext to retrieve the member object that sent the command.
Changes proposed
- Add fresh member objects to message create/update.
- Add new property in the
DiscordConfiguration
to specify whether members should be cached if no privileged intents are enabled. - Consolidate member/user updating and caching into one method, which currently supports 5 events.
- Feature functionality to check state of the client's intents, and caches the new member according to the outcomes above.