public override void ExecuteCommand(EvtChatCommandArgs args) { List <string> arguments = args.Command.ArgumentsAsList; int argCount = arguments.Count; //Ignore with the incorrect number of arguments if (argCount != 2) { QueueMessage(UsageMessage); return; } string commandName = arguments[0].ToLowerInvariant(); string enabledStr = arguments[1]; bool cmdEnabled = false; using (BotDBContext context = DatabaseManager.OpenContext()) { //Find the command CommandData cmdData = context.Commands.FirstOrDefault(c => c.Name == commandName); if (cmdData == null) { QueueMessage($"Cannot find a command named \"{commandName}\"."); return; } if (bool.TryParse(enabledStr, out cmdEnabled) == false) { QueueMessage("Incorrect command enabled state specified."); return; } cmdData.Enabled = (cmdEnabled == true) ? 1 : 0; context.SaveChanges(); } BaseCommand baseCmd = CmdHandler.GetCommand(commandName); baseCmd.Enabled = cmdEnabled; QueueMessage($"Successfully set the enabled state of command \"{commandName}\" to {cmdEnabled}!"); }
public override void ExecuteCommand(EvtChatCommandArgs args) { List <string> arguments = args.Command.ArgumentsAsList; //Ignore with incorrect number of arguments if (arguments.Count != 1) { QueueMessage(UsageMessage); return; } string commandName = arguments[0].ToLowerInvariant(); BaseCommand cmd = CmdHandler.GetCommand(commandName); if (cmd == null) { QueueMessage($"Command \"{commandName}\" not found. If you added or removed commands, update with the reload command."); return; } //Show information about the command QueueMessage($"\"{commandName}\" - Type: {cmd.GetType().FullName} | Level: {cmd.Level} ({(PermissionLevels)cmd.Level}) | Enabled: {cmd.Enabled} | DisplayInHelp: {cmd.DisplayInHelp} | ValueStr: {cmd.ValueStr}"); }