private async Task OnEventReceived(int shardId, IGatewayEvent evt) { // we HandleGatewayEvent **before** getting the own user, because the own user is set in HandleGatewayEvent for ReadyEvent await _cache.HandleGatewayEvent(evt); var userId = await _cache.GetOwnUser(); await _cache.TryUpdateSelfMember(userId, evt); await OnEventReceivedInner(shardId, evt); }
private async Task OnEventReceived(int shardId, IGatewayEvent evt) { // we HandleGatewayEvent **before** getting the own user, because the own user is set in HandleGatewayEvent for ReadyEvent await _cache.HandleGatewayEvent(evt); var userId = await _cache.GetOwnUser(); await _cache.TryUpdateSelfMember(userId, evt); // HandleEvent takes a type parameter, automatically inferred by the event type // It will then look up an IEventHandler<TypeOfEvent> in the DI container and call that object's handler method // For registering new ones, see Modules.cs if (evt is MessageCreateEvent mc) { await HandleEvent(shardId, mc); } if (evt is MessageUpdateEvent mu) { await HandleEvent(shardId, mu); } if (evt is MessageDeleteEvent md) { await HandleEvent(shardId, md); } if (evt is MessageDeleteBulkEvent mdb) { await HandleEvent(shardId, mdb); } if (evt is MessageReactionAddEvent mra) { await HandleEvent(shardId, mra); } if (evt is InteractionCreateEvent ic) { await HandleEvent(shardId, ic); } }