using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
namespace Discord.Interactions
{
///
/// Represents a cached argument constructor delegate.
///
/// Method arguments array.
///
/// Returns the constructed object.
///
public delegate object ComplexParameterInitializer(object[] args);
///
/// Represents the parameter info class for commands.
///
public class SlashCommandParameterInfo : CommandParameterInfo
{
internal readonly ComplexParameterInitializer _complexParameterInitializer;
///
public new SlashCommandInfo Command => base.Command as SlashCommandInfo;
///
/// Gets the description of the Slash Command Parameter.
///
public string Description { get; }
///
/// Gets the minimum value permitted for a number type parameter.
///
public double? MinValue { get; }
///
/// Gets the maximum value permitted for a number type parameter.
///
public double? MaxValue { get; }
///
/// Gets the minimum length allowed for a string type parameter.
///
public int? MinLength { get; }
///
/// Gets the maximum length allowed for a string type parameter.
///
public int? MaxLength { get; }
///
/// Gets the that will be used to convert the incoming into
/// .
///
public TypeConverter TypeConverter { get; }
///
/// Gets the that's linked to this parameter.
///
public IAutocompleteHandler AutocompleteHandler { get; }
///
/// Gets whether this parameter is configured for Autocomplete Interactions.
///
public bool IsAutocomplete { get; }
///
/// Gets whether this type should be treated as a complex parameter.
///
public bool IsComplexParameter { get; }
///
/// Gets the Discord option type this parameter represents. If the parameter is not a complex parameter.
///
public ApplicationCommandOptionType? DiscordOptionType => TypeConverter?.GetDiscordType();
///
/// Gets the parameter choices of this Slash Application Command parameter.
///
public IReadOnlyCollection Choices { get; }
///
/// Gets the allowed channel types for this option.
///
public IReadOnlyCollection ChannelTypes { get; }
///
/// Gets the constructor parameters of this parameter, if is .
///
public IReadOnlyCollection ComplexParameterFields { get; }
internal SlashCommandParameterInfo(Builders.SlashCommandParameterBuilder builder, SlashCommandInfo command) : base(builder, command)
{
TypeConverter = builder.TypeConverter;
AutocompleteHandler = builder.AutocompleteHandler;
Description = builder.Description;
MaxValue = builder.MaxValue;
MinValue = builder.MinValue;
MinLength = builder.MinLength;
MaxLength = builder.MaxLength;
IsComplexParameter = builder.IsComplexParameter;
IsAutocomplete = builder.Autocomplete;
Choices = builder.Choices.ToImmutableArray();
ChannelTypes = builder.ChannelTypes.ToImmutableArray();
ComplexParameterFields = builder.ComplexParameterFields?.Select(x => x.Build(command)).ToImmutableArray();
_complexParameterInitializer = builder.ComplexParameterInitializer;
}
}
}