/// <summary> /// Removes all Commands of the specific Type from the CommandsByAlias. /// </summary> /// <returns>True if any commands have been removed, otherwise false.</returns> //public static bool Remove(Type cmdType) { // Command cmd = Get(cmdType); // if (cmd != null) { // Remove(cmd); // return true; // } // return false; //} /// <summary> /// Gives help /// TODO: Localization /// </summary> public void TriggerHelp(CmdTrigger <C> trigger, bool ignoreRestrictions) { if (trigger.Text.HasNext) { // help for a specific command var cmdStr = trigger.Text.Remainder; var cmds = GetCommands(cmdStr); var count = cmds.Count; foreach (var cmd in cmds) { if (MayDisplay(trigger, cmd, ignoreRestrictions)) { DisplayCmd(trigger, cmd, ignoreRestrictions, true); } else { count--; } } if (count == 0) { trigger.ReplyFormat("Did not find any Command that matches '{0}'.", cmdStr); } } else { // help for all commands var count = 0; foreach (var cmd in Commands) { if (MayDisplay(trigger, cmd, ignoreRestrictions)) { count++; } } trigger.ReplyFormat("Use: ? <Alias> [<subalias> [<subalias> ...]] for help on a certain command."); trigger.Reply("All {0} available commands:", count); foreach (var cmd in Commands) { if (MayDisplay(trigger, cmd, ignoreRestrictions)) { trigger.Reply(cmd.CreateUsage(trigger)); } } } }
/// <summary> /// Gives help /// TODO: Localization /// </summary> public void TriggerHelp(CmdTrigger <C> trigger, bool ignoreRestrictions) { if (trigger.Text.HasNext) { string remainder = trigger.Text.Remainder; List <BaseCommand <C> > commands = this.GetCommands(remainder); int count = commands.Count; foreach (BaseCommand <C> cmd in commands) { if (this.MayDisplay(trigger, cmd, ignoreRestrictions)) { this.DisplayCmd(trigger, cmd, ignoreRestrictions, true); } else { --count; } } if (count != 0) { return; } trigger.ReplyFormat("Did not find any Command that matches '{0}'.", (object)remainder); } else { int num = 0; foreach (Command <C> command in (IEnumerable <Command <C> >) this.Commands) { if (this.MayDisplay(trigger, (BaseCommand <C>)command, ignoreRestrictions)) { ++num; } } trigger.ReplyFormat("Use: ? <Alias> [<subalias> [<subalias> ...]] for help on a certain command."); trigger.Reply("All {0} available commands:", (object)num); foreach (Command <C> command in (IEnumerable <Command <C> >) this.Commands) { if (this.MayDisplay(trigger, (BaseCommand <C>)command, ignoreRestrictions)) { trigger.Reply(command.CreateUsage(trigger)); } } } }
public override void ReplyFormat(string text) { m_Trigger.ReplyFormat(text); }