#pragma warning disable IDE0063 internal static async Task Bot_CommandExecuted(CommandExecutionEventArgs e) { semaphore.Wait(); try { using (StreamWriter sw = new StreamWriter(Program.Files.LogFile, true)) { DateTimeOffset dto = DateTimeOffset.UtcNow; string timeStamp = dto.ToString(Generics.DateFormat); await sw.WriteAsync( value : String.Format("[{0}] '{1}' CALLED BY '{2}' ID '{3}' WITH ARGUMENTS '{4}'\n", timeStamp, e.Command.Name, $"{e.Context.Member.Username}#{e.Context.Member.Discriminator}", e.Context.Member.Id, e.Context.RawArgumentString)); } } finally { semaphore.Release(); } }
//command execution log private Task commandsExecuted(CommandExecutionEventArgs e) { //log name of command and the user e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "Zero Two Bot", $"{e.Context.User.Username} issued the command '{e.Command.QualifiedName}'", DateTime.Now); return(Task.CompletedTask); }
private void OnCommandFinished(object sender, CommandExecutionEventArgs e) { if (_log != null) { _log.WriteLine(string.Format("#{0} Command completed in {1}", e.CommandId, e.Duration), "Information"); } }
/// <summary> /// Executes a SQL statement against a connection object. /// </summary> /// <returns>The number of rows affected.</returns> public override int ExecuteNonQuery() { CommandExecutionEventArgs e = new CommandExecutionEventArgs(this, "ExecuteNonQuery"); e.Status = CommandExecutionStatus.Executing; Stopwatch sw = new Stopwatch(); this.Connection.RaiseExecuting(e); try { sw.Start(); int result = base.ExecuteNonQuery(); sw.Stop(); e.Result = result; e.Duration = sw.Elapsed; e.Status = CommandExecutionStatus.Finished; this.Connection.RaiseFinished(e); return result; } catch (Exception ex) { e.Result = ex; e.Status = CommandExecutionStatus.Failed; this.Connection.RaiseFailed(e); throw; } }
private Task CommandsNext_CommandExecuted(CommandsNextExtension sender, CommandExecutionEventArgs e) { e.Context.Client.Logger.LogInformation(LogEvent, $"User '{e.Context.User.Username}#{e.Context.User.Discriminator}' ({e.Context.User.Id}) executed '{e.Command.QualifiedName}' in #{e.Context.Channel.Name} ({e.Context.Channel.Id})", DateTime.Now); return(Task.CompletedTask); }
private async Task OnCommandExecuted(CommandsNextExtension cne, CommandExecutionEventArgs e) { if (m_AutoDeleteCommands.Contains(e.Command.Name)) { await e.Context.Message.DeleteAsync(); } }
private async Task CommandExecuted(CommandExecutionEventArgs e) { var command = e.Command; var context = e.Context; var guild = context.Guild; var channel = context.Channel; var message = context.Message; var user = context.User; if (!channel.IsPrivate) { if (channel != null && user != null) { _logger.Information($"The command '{command.Name}' has been executed by '{user.GetUsertag()}' in the channel '{channel.Name}' ({channel.Id}) on the guild '{guild.Name}' ({guild.Id})."); await channel.DeleteMessageByIdAsync(message.Id); } else { _logger.Information($"The command '{command.Name}' has been executed by an unknown user in a deleted channel on a unknown guild."); } } else { _logger.Information($"The command '{command.Name}' has been executed by '{user.GetUsertag()}' ({user.Id}) in the direct message."); } }
private void AppendToLog(object sender, CommandExecutionEventArgs e) { if (logger != null) { logger.Debug(e.ToTraceString().TrimEnd()); } }
public static Task RespondSuccessAsync(CommandsNextExtension cnext, CommandExecutionEventArgs e) { // let's log the name of the command and user e.Context.Client.Logger.LogInformation(DiscordBot.Event_CommandResponder, $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'", DateTime.Now); return(Task.CompletedTask); }
//Task to the commands private Task Commands_CommandExecuted(CommandExecutionEventArgs e) { //log the name of the command and the user e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "DiscordBot", $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'", DateTime.Now); return(Task.CompletedTask); }
private Task CommandsOnCommandExecuted(CommandExecutionEventArgs e) { e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "SoT", $"{e.Context.User.Username}#{e.Context.User.Discriminator} ran the command " + $"({e.Command.Name}).", DateTime.Now.ToUniversalTime()); return(Task.CompletedTask); }
private Task CommandsNext_CommandExecuted(CommandExecutionEventArgs e) { e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, LOG_TAG, $"User '{e.Context.User.Username}#{e.Context.User.Discriminator}' ({e.Context.User.Id}) executed '{e.Command.QualifiedName}' in #{e.Context.Channel.Name} ({e.Context.Channel.Id})", DateTime.Now); return(Task.CompletedTask); }
private void OnCommandFailed(object sender, CommandExecutionEventArgs e) { if (_log != null) { _log.WriteLine(string.Format("#{0} Command failed {1}", e.CommandId, e.Result), "Error"); } }
private void OnCommandExecuting(object sender, CommandExecutionEventArgs e) { if (_log != null) { _log.WriteLine(string.Format("#{0} Running {1}:\r\n{2}", e.CommandId, e.Method.Trim(), e.ToTraceString().Trim()), "Information"); } }
/// <summary> /// The logging method. Overwrite this method to change the logging strategy. /// </summary> /// <param name="e"> /// The DB command event. /// </param> /// <param name="commState"> /// Command State /// </param> private void LogSql(CommandExecutionEventArgs e, CommandState commState) { switch (commState) { case CommandState.CommandExecuting: stopwatch.Start(); log.InfoFormat( "[Database: {0}] - Executing command {1}", e.Command.Connection.Database, e.ToTraceString()); break; case CommandState.CommandFailed: stopwatch.Stop(); log.InfoFormat( "[Database: {0}] - Executing command {1} was FAILED", e.Command.Connection.Database, e.ToTraceString()); break; case CommandState.CommandFinished: stopwatch.Stop(); if (stopwatch.ElapsedMilliseconds > MaxTimeAllowPerServiceMethod) { log.WarnFormat("Execute for command take: [{0} ms], it is exceed 2s", stopwatch.ElapsedMilliseconds); } log.InfoFormat("Finished execute command. It takes: {0} millisecond", stopwatch.ElapsedMilliseconds); break; } }
public static Task Command_Executed(CommandExecutionEventArgs e) { e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "PotatoBot", $"[{e.Context.User.Username}] successfully executed '{e.Command.QualifiedName}'", DateTime.Now); Stats.CommandsExecuted++; return(Task.CompletedTask); }
private Task CommandExecuted(CommandExecutionEventArgs commandExecutionEventArgs) { if (commandExecutionEventArgs.Command.Module.GetInstance(commandExecutionEventArgs.Context.Services) is SkiCommandModule skiCommandModule) { skiCommandModule.LogMessage(commandExecutionEventArgs.Context, $"{commandExecutionEventArgs.Command.Name} executed"); } return(SetTimer()); }
private Task Commands_CommandExecuted(CommandExecutionEventArgs e) { // let's log the name of the command and user e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "SWGOHBot", $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'", DateTime.Now); // since this method is not async, let's return a completed task, so that no additional work is done return(Task.CompletedTask); }
private Task Commands_CommandExecuted(CommandExecutionEventArgs e) { e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "ConverterBot", $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'", DateTime.Now); return(Task.CompletedTask); }
private void AppendToLog(object sender, CommandExecutionEventArgs e) { if (this.logOutput != null) { this.logOutput.WriteLine(e.ToTraceString().TrimEnd()); this.logOutput.WriteLine(); } }
private async Task Commands_CommandExecuted(CommandsNextExtension extension, CommandExecutionEventArgs e) { if (LogExecutedCommands) { _logger.Info(GetCommandInfo(e.Context)); await _diagnosticService.AddExecutedCommandAsync(e.Command, e.Context.Guild); } }
private static Task Commands_CommandExecuted(CommandExecutionEventArgs e) { Log .Logger .ForContext(e.Command.Name, e.Command) .Information("{User} ran {Command}.", e.Context.User, e.Command); return(Task.CompletedTask); }
private async Task Command_Executed(CommandExecutionEventArgs e) { var user = e.Context.Member.Nickname ?? e.Context.Member.DisplayName; var message = $"{user}#{e.Context.Member.Discriminator} successfully executed '{e.Command.QualifiedName}'"; await Services.GetRequiredService <Logger>() .LogAsync(new LogMessage(LogLevel.Debug, $"Winson {e.Context.Client.ShardId} - {e.Context.Guild.Name}", message)); }
private Task OnCommandExecuted(CommandExecutionEventArgs args) { string logMessage = $"`{args.Context.User.Username}` ran `{args.Context.Message.Content}` in **[{args.Context.Guild?.Name ?? "DM"} - {args.Context.Channel.Name}]**"; Log.Debug(logMessage); return(Task.CompletedTask); }
public static async Task LogOnCommandExecuted(CommandsNextExtension ctx, CommandExecutionEventArgs e) { var command = (e.Command.Parent != null ? e.Command.Parent.Name + " " : "") + e.Command.Name; e.Context.Client.Logger.LogInformation(BotLoggerEvents.Event, $"Пользователь {e.Context.User.Username}#{e.Context.User.Discriminator} ({e.Context.User.Id}) выполнил команду {command}"); await Task.CompletedTask; //Пришлось добавить, выдавало ошибку при компиляции }
// user executed a command internal static Task CommandExecuted(CommandExecutionEventArgs e) { // logs the name and the command executed e.Context.Client.DebugLogger.LogMessage(LogLevel.Info, "RoleBot", $"{e.Context.User.Username} successfully executed {e.Command.QualifiedName}", DateTime.Now); // not async so return(Task.CompletedTask); }
private Task Commands_CommandExecuted(CommandExecutionEventArgs e) { e.Context.Client.DebugLogger .LogMessage(LogLevel.Info, "FloppyEars", $"{e.Context.User.Username} successfully executed '{e.Command.QualifiedName}'", DateTime.Now); SelfAudit.LogSomething(e.Context.Member, e.Command.QualifiedName, e.Context.RawArgumentString).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }
public static Task CommandExecutionEventHandler(TheGodfatherShard shard, CommandExecutionEventArgs e) { shard.Log(LogLevel.Info, $"| Executed: {e.Command?.QualifiedName ?? "<unknown command>"}\n" + $"| {e.Context.User.ToString()}\n" + $"| {e.Context.Guild.ToString()}; {e.Context.Channel.ToString()}" ); return(Task.CompletedTask); }
private static Task Commands_CommandExecuted(CommandExecutionEventArgs e) { e.Context.Client.DebugLogger.LogMessage(DSharpPlus.LogLevel.Info, "Splash", $"{e.Context.User.Username} executed '{e.Command.QualifiedName}' [{e.Context.Message.Content}]", DateTime.Now); return(Task.CompletedTask); }
private Task LogExecutedCommand(CommandExecutionEventArgs e) { _logger.LogInformation("Executed command '{0}' for user '{1}' in guild '{2}'", e.Command.Name, e.Context.User.ToString(), e.Context.Guild.Name ?? "N/A (Direct Message)"); return(Task.CompletedTask); }
public static Task CommandExecutionEventHandler(FreudShard shard, CommandExecutionEventArgs e) { shard.LogMany(LogLevel.Info, $"Executed: {e.Command?.QualifiedName ?? "<unknown command>"}", $"{e.Context.User.ToString()}", $"{e.Context.Guild.ToString()}; {e.Context.Channel.ToString()}"); return(Task.CompletedTask); }
/// <summary> /// Executes the command text against the connection. /// </summary> /// <param name="behavior">An instance of <see cref="T:System.Data.CommandBehavior"/>.</param> /// <returns> /// A <see cref="T:System.Data.Common.DbDataReader"/>. /// </returns> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { CommandExecutionEventArgs e = new CommandExecutionEventArgs(this, "ExecuteReader"); e.Status = CommandExecutionStatus.Executing; this.Connection.RaiseExecuting(e); try { Stopwatch sw = new Stopwatch(); sw.Start(); DbDataReader result = base.ExecuteDbDataReader(behavior); sw.Stop(); e.Result = result; e.Status = CommandExecutionStatus.Finished; e.Duration = sw.Elapsed; this.Connection.RaiseFinished(e); return result; } catch (Exception ex) { e.Result = ex; e.Status = CommandExecutionStatus.Failed; this.Connection.RaiseFailed(e); throw; } }
private void AppendToLog(object sender, CommandExecutionEventArgs e) { if (this.logOutput != null) { this.logOutput.WriteLine(e.ToTraceString().TrimEnd()); this.logOutput.WriteLine(); } }