public MessageDeletedHandler(DiscordSocketClient client, ChannelStats channelStats, Logger logger, CalledEventStats calledEventStats) { Client = client; Statistics = channelStats; Logger = logger; CalledEventStats = calledEventStats; }
public UserJoinedHandler(DiscordSocketClient client, IOptions <Configuration> config, Logger logger, CalledEventStats calledEventStats) { Client = client; Logger = logger; CalledEventStats = calledEventStats; Config = config.Value; }
public GuildMemberUpdatedHandler(DiscordSocketClient client, Logger logger, CalledEventStats calledEventStats) { Logger = logger; Client = client; CalledEventStats = calledEventStats; Client.GuildMemberUpdated += OnGuildMemberUpdatedAsync; }
public GrillBotService(IServiceProvider services, DiscordSocketClient client, CommandService commands, IOptions <Configuration> config, CalledEventStats calledEventStats, InitService initService) { Services = services; Client = client; Commands = commands; Config = config.Value; CalledEventStats = calledEventStats; InitService = initService; Client.Ready += OnClientReadyAsync; }
public MessageReceivedHandler(DiscordSocketClient client, CommandService commands, IOptions <Configuration> config, IServiceProvider services, ChannelStats channelStats, AutoReplyService autoReply, EmoteChain emoteChain, CalledEventStats calledEventStats, Statistics statistics, EmoteStats emoteStats) { Client = client; Commands = commands; Services = services; ChannelStats = channelStats; AutoReply = autoReply; EmoteChain = emoteChain; CalledEventStats = calledEventStats; Statistics = statistics; EmoteStats = emoteStats; Config = config.Value; }
public async Task PrintEventStatistics() { await DoAsync(async() => { var data = CalledEventStats.ToFormatedDictionary(); if (data.Count == 0) { throw new ArgumentException("Ještě nebyla zavolána žádná událost."); } var embed = new BotEmbed(Context.Message.Author, title: "Statistika zavolaných událostí") .WithFields( new EmbedFieldBuilder().WithName("Událost").WithValue(string.Join("\n", data.Select(o => o.Key))).WithIsInline(true), new EmbedFieldBuilder().WithName("Počet").WithValue(string.Join("\n", data.Select(o => o.Value))).WithIsInline(true) ); await ReplyAsync(embed: embed.Build()).ConfigureAwait(false); }).ConfigureAwait(false); }
public UserLeftHandler(DiscordSocketClient client, Logger logger, CalledEventStats calledEventStats) { Client = client; Logger = logger; CalledEventStats = calledEventStats; }
public ReactionAddedHandler(DiscordSocketClient client, EmoteStats emoteStats, CalledEventStats calledEventStats) { Client = client; EmoteStats = emoteStats; CalledEventStats = calledEventStats; }
private async Task OnMessageReceivedAsync(SocketMessage message) { CalledEventStats.Increment("MessageReceived"); var messageStopwatch = new Stopwatch(); messageStopwatch.Start(); try { if (!TryParseMessage(message, out SocketUserMessage userMessage)) { return; } var commandStopwatch = new Stopwatch(); var context = new SocketCommandContext(Client, userMessage); if (message.Channel is IPrivateChannel && !Config.IsUserBotAdmin(userMessage.Author.Id)) { return; } int argPos = 0; if (userMessage.HasStringPrefix(Config.CommandPrefix, ref argPos) || userMessage.HasMentionPrefix(Client.CurrentUser, ref argPos)) { await LogCommandAsync(userMessage, context, argPos).ConfigureAwait(false); commandStopwatch.Start(); var result = await Commands.ExecuteAsync(context, userMessage.Content.Substring(argPos), Services).ConfigureAwait(false); commandStopwatch.Stop(); if (!result.IsSuccess && result.Error != null) { switch (result.Error.Value) { case CommandError.UnknownCommand: return; case CommandError.UnmetPrecondition: case CommandError.ParseFailed: await context.Channel.SendMessageAsync(result.ErrorReason.PreventMassTags()).ConfigureAwait(false); break; case CommandError.BadArgCount: await SendCommandHelp(context, argPos).ConfigureAwait(false); break; default: throw new BotException(result); } } var command = message.Content.Split(' ')[0]; Statistics.LogCall(command, commandStopwatch.ElapsedMilliseconds); await EmoteChain.CleanupAsync(context.Channel, true).ConfigureAwait(false); } else { await ChannelStats.IncrementCounterAsync(userMessage.Channel).ConfigureAwait(false); await AutoReply.TryReplyAsync(userMessage).ConfigureAwait(false); await EmoteChain.ProcessChainAsync(context).ConfigureAwait(false); await EmoteStats.AnylyzeMessageAndIncrementValuesAsync(context).ConfigureAwait(false); } } finally { messageStopwatch.Stop(); Statistics.ComputeAvgReact(messageStopwatch.ElapsedMilliseconds); } }
public GetBotStatusModule(CalledEventStats calledEventStats, BotStatusService botStatusService) { CalledEventStats = calledEventStats; BotStatusService = botStatusService; }
public MessageEditedHandler(DiscordSocketClient client, Logger logger, CalledEventStats calledEventStats) { Client = client; Logger = logger; CalledEventStats = calledEventStats; }
private async Task OnClientReadyAsync() { CalledEventStats.Increment("Ready"); await InitService.InitAsync().ConfigureAwait(false); }