private async Task OnMessageDeletedAsync(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel) { InternalStatistics.IncrementEvent("MessageDeleted"); if (channel is IPrivateChannel || (message.HasValue && !message.Value.Author.IsUser())) { return; } SocketGuildUser user = null; if (message.HasValue && message.Value.Author is SocketGuildUser guildUser) { user = guildUser; } else if (MessageCache.Exists(message.Id)) { var author = MessageCache.Get(message.Id).Author; user = author is SocketGuildUser socketGuildUser ? socketGuildUser : null; } using var scope = Provider.CreateScope(); if (user != null) { await scope.ServiceProvider.GetService <UserMessagesService>().DecrementMessageStats(user.Guild, user, channel); } await Logger.OnMessageDelete(message, channel).ConfigureAwait(false); PaginationService.DeleteEmbed(message.Id); }