private async Task OnReactionAddedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { InternalStatistics.IncrementEvent("ReactionAdded"); using var scope = Provider.CreateScope(); await scope.ServiceProvider.GetService <EmoteStats>().IncrementFromReactionAsync(reaction); if (reaction.User.IsSpecified && reaction.User.Value.IsUser()) { await PaginationService.HandleReactionAsync(reaction); await scope.ServiceProvider.GetService <UserReactionsService>().IncrementReactionStatsAsync(reaction); await scope.ServiceProvider.GetService <ReminderService>().HandleRemindCopyAsync(reaction); if (channel is SocketTextChannel textChannel) { await scope.ServiceProvider.GetService <PointsService>().IncrementPointsAsync(textChannel.Guild, reaction); } if (message.HasValue) { await scope.ServiceProvider.GetService <ReminderService>().PostponeReminderAsync(message.Value, reaction); } } }
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); }
private async Task OnUserLeftAsync(SocketGuildUser user) { InternalStatistics.IncrementEvent("UserLeft"); await Logger.OnUserLeft(user).ConfigureAwait(false); using var scope = Provider.CreateScope(); await scope.ServiceProvider.GetService <UnverifyService>().OnUserLeftGuildAsync(user); }
private async Task OnClientReadyAsync() { InternalStatistics.IncrementEvent("Ready"); await InitService.InitAsync(); await SetActivityAsync(); }
private async Task OnUserUnbannedAsync(SocketUser user, SocketGuild guild) { InternalStatistics.IncrementEvent("UserUnbanned"); using var scope = ServiceProvider.CreateScope(); var auditService = scope.ServiceProvider.GetService <AuditService>(); await auditService.RunTaskAsync(ActionType.Unban, guild); }
private async Task OnReactionAddedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { InternalStatistics.IncrementEvent("ReactionAdded"); EmoteStats.IncrementFromReaction(reaction); await PaginationService.HandleReactionAsync(reaction); UserService.IncrementReaction(reaction); }
private async Task OnUserJoinedOnServerAsync(SocketGuildUser user) { InternalStatistics.IncrementEvent("UserJoined"); await Logger.OnUserJoined(user).ConfigureAwait(false); using var scope = Services.CreateScope(); var inviteTracker = scope.ServiceProvider.GetService <InviteTrackerService>(); await inviteTracker.OnUserJoinedAsync(user); }
private async Task OnReactionRemovedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { InternalStatistics.IncrementEvent("ReactionRemoved"); using var scope = Provider.CreateScope(); await scope.ServiceProvider.GetService <EmoteStats>().DecrementFromReactionAsync(reaction); await scope.ServiceProvider.GetService <UserReactionsService>().DecrementReactionStatsAsync(reaction); }
private async Task OnUserJoinedOnServerAsync(SocketGuildUser user) { InternalStatistics.IncrementEvent("UserJoined"); using var scope = Services.CreateScope(); await scope.ServiceProvider.GetService <AuditService>().LogUserJoinAsync(user); await scope.ServiceProvider.GetService <InviteTrackerService>().OnUserJoinedAsync(user); }
private async Task OnGuildMemberUpdatedAsync(SocketGuildUser guildUserBefore, SocketGuildUser guildUserAfter) { if (LastEventAt != DateTime.MinValue && (DateTime.UtcNow - LastEventAt).TotalSeconds < 1.0D) { return; } InternalStatistics.IncrementEvent("GuildMemberUpdated"); using var scope = Provider.CreateScope(); await scope.ServiceProvider.GetService <AuditService>().ProcessBoostChangeAsync(guildUserBefore, guildUserAfter); LastEventAt = DateTime.UtcNow; }
private async Task OnMessageUpdatedAsync(Cacheable <IMessage, ulong> messageBefore, SocketMessage messageAfter, ISocketMessageChannel channel) { InternalStatistics.IncrementEvent("MessageUpdated"); if (!messageAfter.Author.IsUser() || channel is IPrivateChannel) { return; } if (channel is SocketGuildChannel guildChannel) { using var scope = Provider.CreateScope(); await scope.ServiceProvider.GetService <AuditService>().LogMessageEditedAsync(messageBefore, messageAfter, channel, guildChannel.Guild); } }
private async Task OnMessageReceivedAsync(SocketMessage message) { InternalStatistics.IncrementEvent("MessageReceived"); if (!TryParseMessage(message, out SocketUserMessage userMessage)) { return; } var context = new SocketCommandContext(Client, userMessage); if (context.IsPrivate) { return; } int argPos = 0; if (IsCommand(userMessage, ref argPos)) { BotState.RunningCommands.Add(message); await Commands.ExecuteAsync(context, userMessage.Content[argPos..], Services).ConfigureAwait(false);
private async Task OnMessageReceivedAsync(SocketMessage message) { InternalStatistics.IncrementEvent("MessageReceived"); if (!TryParseMessage(message, out SocketUserMessage userMessage)) { return; } var context = new SocketCommandContext(Client, userMessage); if (context.IsPrivate) { return; } int argPos = 0; if (userMessage.HasStringPrefix(Config.CommandPrefix, ref argPos) || userMessage.HasMentionPrefix(Client.CurrentUser, ref argPos)) { await Commands.ExecuteAsync(context, userMessage.Content.Substring(argPos), Services).ConfigureAwait(false); if (context.Guild != null) { EmoteChain.CleanupAsync((SocketGuildChannel)context.Channel); } } else { if (context.Guild != null) { UserService.IncrementMessage(context.User as SocketGuildUser, context.Guild, context.Channel as SocketGuildChannel); await AutoReply.TryReplyAsync(context.Guild, userMessage).ConfigureAwait(false); } await EmoteChain.ProcessChainAsync(context).ConfigureAwait(false); EmoteStats.AnylyzeMessageAndIncrementValues(context); } }
private async Task OnReactionRemovedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { InternalStatistics.IncrementEvent("ReactionRemoved"); EmoteStats.DecrementFromReaction(reaction); UserService.DecrementReaction(reaction); }
private async Task OnClientReadyAsync() { InternalStatistics.IncrementEvent("Ready"); await InitService.InitAsync().ConfigureAwait(false); }