Closed Incapamentum closed 1 year ago
Turns out that there are such things as Guild-specific events. More precisely, there are (at the time of writing this comment) exactly two events specific to Guild Members.
The difference? User-specific events handle things that directly affect the Discord user, but not necessarily the Guild user. This is where events such as GuildMemberUpdated
come into play. If a user of a server gets updated, say changes their server profile or gets a new role, this event is fired.
Wanted to document these differences for transparency and clarity. I'll have to create a new event-handler and move code over from the UserEventHandler
to GuildMemberEventHandler
. I think it's not ideal to have both together since they deal with distinct entities, even if one is a child of the other.
Another thing to point out: the signature of the aforementioned event is Func<Cacheable<SocketGuildUser, Uint64>, SocketGuildUser, Task> GuildMemberUpdated
. The cache should always be updated when the bot goes live (this should be confirmed), and it's been (somewhat) confirmed that the first instance of SocketUser
is the previous, the second instance is the current. This applies to the function signature as well.
As the title states.
This should be a straight-forward implementation. Simply just check to see whether the user has lost the
Gilded
role to give them theExplorer
role.This does not mean to give the
Explorer
role IFF the user doesn't have theGilded
role (this should be confirmed), but should check for effectively a before and after state. I think this event will be needed. It has a signature ofFunc<SocketUser, SocketUser, Task> UserUpdated
.Although not explicit, I have an assumption that the first reference to a
SocketUser
is a before state, with the second reference being an after state. Will have to confirm.This can be implemented as a FSM. The database should also be updated with a new doc within the
roles
category.