public void Run(IPlayer player, int groupId, CmdArgs args) { string arg = args.PopWord()?.ToLowerInvariant(); if (arg != null) { if (SubCommands.ContainsKey(arg)) { SubCommands[arg].Run(player, groupId, args); return; } else { args.PushSingle(arg); } } Command.Invoke(player, groupId, args); }
public ClientChatCommandExt(ICoreClientAPI capi) { this.capi = capi; RegisterSubCommand("help", new SubCommand((a, b, c) => { string arg = c.PopWord()?.ToLowerInvariant(); if (arg != null && SubCommands.ContainsKey(arg)) { capi.ShowChatMessage(SubCommands[arg].Description); } else { if (arg == null) { capi.ShowChatMessage(string.Format("Please provide an argument you need help with. Type .help {0} for syntax.", Command)); } else { capi.ShowChatMessage(string.Format("No such argument '{0}' exists.", arg)); } } }, "Gets help for specified subcommand")); }