internal CommandOptionBuilder(List <CommandOption> parent, CommandOptionType type, string name, string description, IApplicationCommandBuilder builder)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(name));
            }
            if (string.IsNullOrEmpty(description))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(description));
            }

            if (type == CommandOptionType.SubCommand || type == CommandOptionType.SubCommandGroup)
            {
                throw new InvalidApplicationCommandException($"{type} is not allowed to be used here. Valid types are any non command type.");
            }

            _option = new CommandOption
            {
                Name        = name,
                Description = description,
                Type        = type
            };
            parent.Add(_option);
            _builder = builder;
        }
Exemplo n.º 2
0
 internal SubCommandBuilder(List <CommandOption> parent, string name, string description, IApplicationCommandBuilder builder)
 {
     _builder = builder;
     _options = new List <CommandOption>();
     parent.Add(new CommandOption
     {
         Name        = name,
         Description = description,
         Type        = CommandOptionType.SubCommand,
         Options     = _options
     });
 }