Beispiel #1
0
        public static async Task OnRelay(string data)
        {
            PlanetMessage  message = JsonConvert.DeserializeObject <PlanetMessage>(data);
            CommandContext ctx     = new CommandContext();
            await ctx.Set(message);

            await EventService.OnMessage(ctx);

            // check to see if message has a command in it

            if (message.Content.Substring(0, 1) == BotPrefix)
            {
                // get clean command string

                string commandstring = message.Content.Replace(BotPrefix, "");

                // get args

                List <string> args = commandstring.Split(" ").ToList();
                args.RemoveAt(0);

                // get command

                string commandname = message.Content.Split(" ")[0].Replace(BotPrefix, "").ToLower();

                CommandInfo command = CommandService.RunCommandString(commandname, args, ctx);

                if (command != null)
                {
                    command.Method.Invoke(command.moduleInfo.Instance, command.ConvertStringArgs(args, ctx).ToArray());
                }
            }
        }