Ejemplo n.º 1
0
 public TemporaryCommandHandler AddCommand(string name, Func<CommandInfo, Task> command)
 {
     try
     {
         BotCommands.Add(name, new BotCommand(command));
         ParentCommandHandler.Logger.LogInfo($"{name}, {command}, {command?.Method?.ToString()}");
     }
     catch(Exception ex)
     {
         ParentCommandHandler.Logger.LogException(ex);
     }
     return this;
 }
Ejemplo n.º 2
0
        public void LoadCommands(CommandService commandService)
        {
            var commands = commandService.GetCommands();

            foreach (var c in commands)
            {
                try
                {
                    // All commands are stored in lower case, bot commands are case insensitive
                    BotCommands.Add(c.Key.ToLower(), new BotCommand(c.Value));
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }

            Logger.LogInfo($"{BotCommands.Count} commands loaded in CommandHandler ({commands.Count()} expected).");
        }