Exemple #1
0
        private void ParseCommand(List <InteractionDataOption> options)
        {
            if (options == null || options.Count == 0)
            {
                return;
            }

            InteractionDataOption option = options[0];

            switch (option.Type)
            {
            case CommandOptionType.SubCommandGroup:
                CommandGroup = option.Name;
                ParseCommand(option.Options);
                break;

            case CommandOptionType.SubCommand:
                SubCommand = option.Name;
                ParseCommand(option.Options);
                break;

            default:
                Args = new InteractionDataArgs(Interaction, options);
                break;
            }
        }
Exemple #2
0
 internal InteractionDataArgs(DiscordInteraction interaction, List <InteractionDataOption> options)
 {
     _interaction = interaction;
     for (int index = 0; index < options.Count; index++)
     {
         InteractionDataOption option = options[index];
         _args[option.Name] = option;
     }
 }
Exemple #3
0
        private InteractionDataOption GetArg(string name, CommandOptionType requested)
        {
            InteractionDataOption arg = _args[name];

            if (arg == null)
            {
                return(null);
            }

            if (arg.Type != CommandOptionType.Mentionable)
            {
                ValidateArgs(name, arg.Type, requested);
            }
            else if (requested != CommandOptionType.Role && requested != CommandOptionType.User)
            {
                throw new Exception($"Attempted to parse {name} role/user type to: {requested} which is not valid.");
            }

            return(arg);
        }