Ejemplo n.º 1
0
 public override void OnInvoke(CommandInvoker invoker, CommandArguments args)
 {
     if (!(args.IsEmpty()) && args.GetArgumentAtPosition(0) == "@off")
     {
         invoker.GetProcessor().Echo = false;
     }
     else if (!(args.IsEmpty()) && args.GetArgumentAtPosition(0) == "@on")
     {
         invoker.GetProcessor().Echo = true;
     }
     else if (!(args.IsEmpty()))
     {
         string s = "";
         for (int i = 0; i < args.Count(); i++)
         {
             var x = args.GetArgumentAtPosition(i);
             if (s == "" || s == null)
             {
                 s = x;
             }
             else
             {
                 s += $" {x}";
             }
         }
         Console.WriteLine(s);
     }
     else
     {
         Console.WriteLine("Huh, somehow we ended up here...?");
     }
 }
Ejemplo n.º 2
0
 public override void OnInvoke(CommandInvoker invoker, CommandArguments args)
 {
     //Check if the argument array is empty.
     if (args.IsEmpty())
     {
         string s = "";
         //Then display commands normally.
         foreach (Command c in invoker.GetCommands().ToArray())
         {
             if (s == "" || s == null)
             {
                 s = $"{c.CommandName()}: {c.CommandDescription()}";
             }
             else
             {
                 s += $"\n{c.CommandName()}: {c.CommandDescription()}";
             }
         }
         Console.WriteLine(s);
     }
     else if (args.GetArgumentAtPosition(0) == "-l" || args.GetArgumentAtPosition(0) == "--list")
     {
         //Display a sorted or organized list.
         string s   = "";
         int    cnt = 1;
         string ln  = "";
         foreach (Command c in invoker.GetCommands().ToArray())
         {
             if (cnt == 5)
             {
                 if (s == "" || s == null)
                 {
                     s   = $"{ln}";
                     ln  = $"{c.CommandName()}";
                     cnt = 1;
                 }
                 else
                 {
                     s  += $"\n{ln}";
                     ln  = $"{c.CommandName()}";
                     cnt = 1;
                 }
             }
             else
             {
                 if (ln == "" || ln == null)
                 {
                     ln = $"{c.CommandName()}";
                 }
                 else
                 {
                     ln += $", {c.CommandName()}";
                 }
                 cnt++;
             }
         }
         Console.WriteLine(s);
     }
     else
     {
         //Display information about a specific command or it's alias.
         var cmd = invoker.GetCommand(args.GetArgumentAtPosition(0));
         if (cmd != null)
         {
             Console.WriteLine(
                 $"==========|HELP|==========\n" +
                 $"Name: {cmd.CommandName()}\n" +
                 $"Description: {cmd.CommandDescription()}\n" +
                 $"Version: {cmd.CommandVersion()}\n" +
                 $"Copyright: {cmd.CommandCopyright()}\n" +
                 $"Aliases: {cmd.CommandAliases().ToString(' ')}\n" +
                 $"==========|HELP|=========="
                 );
         }
         else
         {
             string s = "";
             //Then display commands normally.
             foreach (Command c in invoker.GetCommands().ToArray())
             {
                 if (s == "" || s == null)
                 {
                     s = $"{c.CommandName()}: {c.CommandDescription()}";
                 }
                 else
                 {
                     s += $"\n{c.CommandName()}: {c.CommandDescription()}";
                 }
             }
             Console.WriteLine(s);
         }
     }
 }