Ejemplo n.º 1
0
            public async Task <Result> Execute(SocketUserMessage e, params object[] arguments)
            {
                for (int i = 0; i < arguments.Length; i++)
                {
                    CommandVariables.Set(e.Id, "arg" + i, arguments [i], true);
                }
                Program.FoundCommandResult result = await Program.FindAndExecuteCommand(e, chain, Program.commands, 0, false, true);

                return(result.result);
            }
Ejemplo n.º 2
0
            private async Task <System.Tuple <int, bool> > CalcY(SocketUserMessage e, string cmd, List <string> args, double x, double xscale, double yscale)
            {
                CommandVariables.Set(e.Id, "x", x, true);

                Program.FoundCommandResult result = await Program.FindAndExecuteCommand(e, cmd, args, Program.commands, 1, false, true);

                double y = (double)Convert.ChangeType(result.result.value, typeof(double));

                int ycur = (int)Math.Round(y / yscale) + Y_RES / 2;

                return(new System.Tuple <int, bool> (ycur, !double.IsNaN(y)));
            }
Ejemplo n.º 3
0
            public async Task <Result> Execute(SocketUserMessage e, double seconds, string command)
            {
                await Task.Delay((int)Math.Round(seconds * 1000));

                string cmd;

                if (command.Length > 1 && command [1].IsTrigger())
                {
                    List <string> args = Utility.ConstructArguments(GetParenthesesArgs(command), out cmd);

                    Program.FoundCommandResult res = await Program.FindAndExecuteCommand(e, cmd.Substring(1), args, Program.commands, 1, true, true);

                    return(new Result(res.result, ""));
                }
                return(new Result(command, ""));
            }
Ejemplo n.º 4
0
        public async Task <List <object> > ConvertChainCommandsToObjects(SocketUserMessage e, List <object> input, int depth)
        {
            List <object> converted = new List <object> ();

            foreach (object obj in input)
            {
                object result    = obj;
                string stringObj = obj.ToString();

                if (stringObj.Length > 0)
                {
                    if (stringObj [0].IsTrigger())
                    {
                        Program.FoundCommandResult foundCommandResult = await Program.FindAndExecuteCommand(e, stringObj, Program.commands, depth + 1, false, true);

                        if (foundCommandResult.result != null)
                        {
                            result = foundCommandResult.result.value;
                        }
                    }
                    else if (stringObj [0] == '{')
                    {
                        int endIndex = stringObj.IndexOf('}');
                        if (endIndex != -1)
                        {
                            string varName = stringObj.Substring(1, endIndex - 1);
                            result = CommandVariables.Get(e.Id, varName);
                        }
                    }
                    else if (stringObj [0] == '<')
                    {
                        IMentionable mentionable = Utility.ConvertMentionToObject(stringObj);
                        result = mentionable;
                    }
                }

                converted.Add(result);
            }

            return(converted);
        }