Esempio n. 1
0
#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();
            }
        }
Esempio n. 2
0
        //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);
        }
Esempio n. 3
0
 private void OnCommandFinished(object sender, CommandExecutionEventArgs e)
 {
     if (_log != null)
     {
         _log.WriteLine(string.Format("#{0} Command completed in {1}", e.CommandId, e.Duration), "Information");
     }
 }
Esempio n. 4
0
 /// <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);
 }
Esempio n. 6
0
 private async Task OnCommandExecuted(CommandsNextExtension cne, CommandExecutionEventArgs e)
 {
     if (m_AutoDeleteCommands.Contains(e.Command.Name))
     {
         await e.Context.Message.DeleteAsync();
     }
 }
Esempio n. 7
0
        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.");
            }
        }
Esempio n. 8
0
 private void AppendToLog(object sender, CommandExecutionEventArgs e)
 {
     if (logger != null)
     {
         logger.Debug(e.ToTraceString().TrimEnd());
     }
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        //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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
 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);
 }
Esempio n. 13
0
 private void OnCommandFailed(object sender, CommandExecutionEventArgs e)
 {
     if (_log != null)
     {
         _log.WriteLine(string.Format("#{0} Command failed {1}", e.CommandId, e.Result), "Error");
     }
 }
Esempio n. 14
0
 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");
     }
 }
Esempio n. 15
0
        /// <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;
            }
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
 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());
 }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
 private void AppendToLog(object sender, CommandExecutionEventArgs e)
 {
     if (this.logOutput != null)
     {
         this.logOutput.WriteLine(e.ToTraceString().TrimEnd());
         this.logOutput.WriteLine();
     }
 }
Esempio n. 21
0
 private async Task Commands_CommandExecuted(CommandsNextExtension extension, CommandExecutionEventArgs e)
 {
     if (LogExecutedCommands)
     {
         _logger.Info(GetCommandInfo(e.Context));
         await _diagnosticService.AddExecutedCommandAsync(e.Command, e.Context.Guild);
     }
 }
Esempio n. 22
0
 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);
 }
Esempio n. 23
0
 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));
 }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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; //Пришлось добавить, выдавало ошибку при компиляции
        }
Esempio n. 26
0
        // 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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
 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);
 }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        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);
        }
Esempio n. 31
0
        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);
        }
Esempio n. 32
0
 /// <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;
     }
 }
Esempio n. 33
0
 private void AppendToLog(object sender, CommandExecutionEventArgs e)
 {
     if (this.logOutput != null)
     {
         this.logOutput.WriteLine(e.ToTraceString().TrimEnd());
         this.logOutput.WriteLine();
     }
 }