예제 #1
0
 public SetDescriptionCommand(DiscordBot bot) : base("set-info", "set the description of an image command")
 {
     _default = SetInfo;
     _bot     = bot;
     RegisterOption('n', n => { _name = n; }, "specify the image name");
     RegisterOption('i', i => { _help = i; }, "specify a description of the image");
 }
예제 #2
0
		public SetDescriptionCommand(DiscordBot bot) : base("set-info", "set the description of an image command")
		{
			_default = SetInfo;
			_bot = bot;
			RegisterOption('n', n => { _name = n; }, "specify the image name");
			RegisterOption('i', i => { _help = i; }, "specify a description of the image");
		}
예제 #3
0
        public DiscordHelpCommand(DiscordBot bot) : base("help", "shows this list")
        {
            _bot     = bot;
            _default = ShowHelp;

            RegisterOption('s', async s =>
            {
                search = true;
                //Karuta.Write("Searching...");
                await _channel.SendMessage("Searching...");
                List <string> output = new List <string>();
                output.Add("");
                int index      = 0;
                string curLine = "";
                foreach (DiscordImageCommand dc in from c in bot.interpreter.GetCommands() orderby c.name where c.GetType() == typeof(DiscordImageCommand) && (c.name.Contains(s) || c.helpMessage.Contains(s)) select c)
                {
                    curLine = $"!{dc.name} {dc.helpMessage} [{dc.images.Count}]\n";
                    if (curLine.Length + output[index].Length >= 1500)
                    {
                        index++;
                        output.Add("");
                    }
                    output[index] += curLine;
                }
                for (int i = 0; i < output.Count; i++)
                {
                    output[i] = output[i].Replace(s, $"**{s}**");
                }
                output[0] = ((string.IsNullOrWhiteSpace(output[0]) && output.Count == 1) ? "No commands found" : $"Search results: \n Page 1 of {output.Count}\n{output[0]}");
                for (int i = 0; i < output.Count; i++)
                {
                    await _channel.SendMessage($"{((i != 0) ? $"Page {i + 1} of {output.Count}\n" : "")} {output[i]}");
                }
            }, "list all commands matching the search parameters");

            init = () =>
            {
                ClearKeywords();
                foreach (DiscordCommand c in from d in bot.interpreter.GetCommands() orderby d.name where d.GetType() != typeof(DiscordImageCommand) select d)
                {
                    RegisterKeyword(c.name, async() =>
                    {
                        //Karuta.Write(c.name);
                        await _channel.SendMessage($"The \"{c.name}\" command:");
                        string output = "";
                        output       += $"  {c.helpMessage} \n";
                        foreach (Keyword k in c.keywords)
                        {
                            output += $"   {k.keyword} {k.usage}\n";
                        }
                        foreach (Option o in c.options)
                        {
                            output += $"   -{o.key} {o.usage}\n";
                        }
                        await _channel.SendMessage(output);
                    });
                }
            };
        }
예제 #4
0
 public AddImageCommand(DiscordBot bot) : base("add-image", "add an image new image command or extend an existing one")
 {
     _default = Add;
     _bot     = bot;
     RegisterOption('n', s => { _name = s; }, "specify the image name");
     RegisterOption('u', s => { _url = s; }, "specify the url of the image");
     RegisterOption('i', s => { _help = s; }, "specify a description of the image");
 }
예제 #5
0
 public RemoveImageCommand(DiscordBot bot) : base("remove-image", "remove an image")
 {
     _default = Remove;
     _bot     = bot;
     RegisterOption('n', s => { _name = s; }, "specify the image name");
     RegisterOption('u', s => { _url = s; }, "specify the url of the image");
     RegisterOption('f', s => { _removeEntirely = true; }, "removes the entire command");
 }
예제 #6
0
		public AddImageCommand(DiscordBot bot) : base("add-image", "add an image new image command or extend an existing one")
		{
			_default = Add;
			_bot = bot;
			RegisterOption('n', s => { _name = s; }, "specify the image name");
			RegisterOption('u', s => { _url = s; }, "specify the url of the image");
			RegisterOption('i', s => { _help = s; }, "specify a description of the image");
		}
예제 #7
0
        public DiscordEventCommand(DiscordBot bot) : base("events", "Add/Remove/View upcoming events")
        {
            _bot    = bot;
            init    = () => Karuta.StartTimer("DiscordEventKeeper", CheckEvents, 0, 60 * 1000);
            _events = new List <DiscordEvent>();

            RegisterKeyword("all", ListEvents, "lists all events");
            RegisterKeyword("add", AddEvent, "adds a new event, options [n]ame, [t]ime, and either [e]vent message or [c]ommand are required. Optional: [r]epeat rate, repeat [m]ode, [s]ervers");
            RegisterKeyword("register", null, "register an exsisting event to be triggered on this channel on this server");
            RegisterOption('n', n => eName    = n, "Specify the name of an event");
            RegisterOption('t', t => eTime    = t, "Specify the time of an event, format: MM/DD/YYYY HH:MM");
            RegisterOption('m', m => eMode    = m, "Specify the mode of an event, Valid modes are: none, daily, weekly, monthly, and anually");
            RegisterOption('e', e => eMessage = e, "Specify the message to be displayed when the even occurs, supports markdown formatting. Must be enclosed with quotes, can be used allongside the [c]ommand option");
            RegisterOption('c', c => eCommand = c, "Specify the name of an iamge command that will be executed when the event occurs, can be used allongside the [e]vent message option");
            RegisterOption('r', r => eRate    = r, "Specify the rate multipler at which events will repeat, for example a value of 2 on an event of mode daily will repeat once every 2 days");
        }
예제 #8
0
		public DiscordEventCommand(DiscordBot bot) : base("events", "Add/Remove/View upcoming events")
		{
			_bot = bot;
			Karuta.StartTimer("DiscordEventKeeper", CheckEvents, 0, 60 * 1000);
			_events = new List<DiscordEvent>();

			RegisterKeyword("all", ListEvents, "lists all events");
			RegisterKeyword("add", AddEvent, "adds a new event, options [n]ame, [t]ime, and either [e]vent message or [c]ommand are required. Optional: [r]epeat rate, repeat [m]ode, [s]ervers");
			RegisterKeyword("register", null, "register an exsisting event to be triggered on this channel on this server");
			RegisterOption('n', n => eName = n, "Specify the name of an event");
			RegisterOption('t', t => eTime = t, "Specify the time of an event, format: MM/DD/YYYY HH:MM");
			RegisterOption('m', m => eMode = m, "Specify the mode of an event, Valid modes are: none, daily, weekly, monthly, and anually");
			RegisterOption('e', e => eMessage = e, "Specify the message to be displayed when the even occurs, supports markdown formatting. Must be enclosed with quotes, can be used allongside the [c]ommand option");
			RegisterOption('c', c => eCommand = c, "Specify the name of an iamge command that will be executed when the event occurs, can be used allongside the [e]vent message option");
			RegisterOption('r', r => eRate = r, "Specify the rate multipler at which events will repeat, for example a value of 2 on an event of mode daily will repeat once every 2 days");
		}
예제 #9
0
 public DiscordPurgeCommand(DiscordBot bot) : base("purge", "purges all data")
 {
     _bot     = bot;
     _default = Purge;
 }
예제 #10
0
 public DiscordSaveCommand(DiscordBot bot) : base("force-save", "force a save")
 {
     _bot     = bot;
     _default = Save;
 }
예제 #11
0
		public DiscordPurgeCommand(DiscordBot bot) : base("purge", "purges all data")
		{
			_bot = bot;
			_default = Purge;
		}
예제 #12
0
		public DiscordSaveCommand(DiscordBot bot) : base("force-save", "force a save")
		{
			_bot = bot;
			_default = Save;
		}
예제 #13
0
		public DiscordHelpCommand(DiscordBot bot) : base("help", "shows this list")
		{
			_bot = bot;
			_default = ShowHelp;

			RegisterOption('s', async s =>
			{
				search = true;
				//Karuta.Write("Searching...");
				await _channel.SendMessage("Searching...");
				List<string> output = new List<string>();
				output.Add("");
				int index = 0;
				string curLine = "";
				foreach (DiscordImageCommand dc in from c in bot.interpreter.commands.Values orderby c.name where c.GetType() == typeof(DiscordImageCommand) && (c.name.Contains(s) || c.helpMessage.Contains(s)) select c)
				{
					curLine = $"!{dc.name} {dc.helpMessage} [{dc.images.Count}]\n";
					if (curLine.Length + output[index].Length >= 1500)
					{
						index++;
						output.Add("");
					}
					output[index] += curLine;
				}
				for (int i = 0; i < output.Count; i++)
				{
					output[i] = output[i].Replace(s, $"**{s}**");
				}
				output[0] = ((string.IsNullOrWhiteSpace(output[0]) && output.Count == 1) ? "No commands found" : $"Search results: \n Page 1 of {output.Count}\n{output[0]}");
				for (int i = 0; i < output.Count; i++)
					await _channel.SendMessage($"{((i != 0) ? $"Page {i + 1} of {output.Count}\n" : "")} {output[i]}");
			}, "list all commands matching the search parameters");

			init = () =>
			{
				ClearKeywords();
				foreach(DiscordCommand c in from d in bot.interpreter.commands.Values orderby d.name where d.GetType() != typeof(DiscordImageCommand) select d)
				{
					RegisterKeyword(c.name, async () =>
					{
						//Karuta.Write(c.name);
						await _channel.SendMessage($"The \"{c.name}\" command:");
						string output = "";
						output += $"  {c.helpMessage} \n";
						foreach (Keyword k in c.keywords)
							output += $"   {k.keyword} {k.usage}\n";
						foreach (Option o in c.options)
							output += $"   -{o.key} {o.usage}\n";
						await _channel.SendMessage(output);
					});
				}
			};
		}
예제 #14
0
		public RemoveImageCommand(DiscordBot bot) : base("remove-image", "remove an image")
		{
			_default = Remove;
			_bot = bot;
			RegisterOption('n', s => { _name = s; }, "specify the image name");
			RegisterOption('u', s => { _url = s; }, "specify the url of the image");
			RegisterOption('f', s => { _removeEntirely = true; }, "removes the entire command");

		}