Class SlashCommandParameterBuilder
- Namespace
- Discord.Interactions.Builders
- Assembly
- Discord.Net.Interactions.dll
Represents a builder for creating SlashCommandParameterInfo.
public sealed class SlashCommandParameterBuilder : ParameterBuilder<SlashCommandParameterInfo, SlashCommandParameterBuilder>, IParameterBuilder
- Inheritance
-
SlashCommandParameterBuilder
- Implements
- Inherited Members
Constructors
SlashCommandParameterBuilder(ICommandBuilder, string, Type, ComplexParameterInitializer)
Initializes a new SlashCommandParameterBuilder.
public SlashCommandParameterBuilder(ICommandBuilder command, string name, Type type, ComplexParameterInitializer complexParameterInitializer = null)
Parameters
command
ICommandBuilderParent command of this parameter.
name
stringName of this command.
type
TypeType of this parameter.
complexParameterInitializer
ComplexParameterInitializer
Properties
Autocomplete
Gets or sets whether this parameter should be configured for Autocomplete Interactions.
public bool Autocomplete { get; set; }
Property Value
AutocompleteHandler
Gets or sets the IAutocompleteHandler of this parameter.
public IAutocompleteHandler AutocompleteHandler { get; set; }
Property Value
ChannelTypes
Gets a collection of the channel types of this command.
public IReadOnlyCollection<ChannelType> ChannelTypes { get; }
Property Value
Choices
Gets a collection of the choices of this command.
public IReadOnlyCollection<ParameterChoice> Choices { get; }
Property Value
ComplexParameterFields
Gets the constructor parameters of this parameter, if IsComplexParameter is true.
public IReadOnlyCollection<SlashCommandParameterBuilder> ComplexParameterFields { get; }
Property Value
ComplexParameterInitializer
Gets the initializer delegate for this parameter, if IsComplexParameter is true.
public ComplexParameterInitializer ComplexParameterInitializer { get; }
Property Value
Description
Gets or sets the description of this parameter.
public string Description { get; set; }
Property Value
Instance
protected override SlashCommandParameterBuilder Instance { get; }
Property Value
IsComplexParameter
Gets whether this type should be treated as a complex parameter.
public bool IsComplexParameter { get; }
Property Value
MaxLength
Gets or sets the maximum length allowed for a string type parameter.
public int? MaxLength { get; set; }
Property Value
- int?
MaxValue
Gets or sets the max value of this parameter.
public double? MaxValue { get; set; }
Property Value
MinLength
Gets or sets the minimum length allowed for a string type parameter.
public int? MinLength { get; set; }
Property Value
- int?
MinValue
Gets or sets the min value of this parameter.
public double? MinValue { get; set; }
Property Value
TypeConverter
Gets or sets the TypeConverter of this parameter.
public TypeConverter TypeConverter { get; }
Property Value
Methods
AddComplexParameterField(Action<SlashCommandParameterBuilder>)
Adds a parameter builders to ComplexParameterFields.
public SlashCommandParameterBuilder AddComplexParameterField(Action<SlashCommandParameterBuilder> configure)
Parameters
configure
Action<SlashCommandParameterBuilder>SlashCommandParameterBuilder factory.
Returns
- SlashCommandParameterBuilder
The builder instance.
Exceptions
- InvalidOperationException
Thrown if the added field has a ComplexParameterAttribute.
AddComplexParameterFields(params SlashCommandParameterBuilder[])
Adds parameter builders to ComplexParameterFields.
public SlashCommandParameterBuilder AddComplexParameterFields(params SlashCommandParameterBuilder[] fields)
Parameters
fields
SlashCommandParameterBuilder[]New parameter builders to be added to ComplexParameterFields.
Returns
- SlashCommandParameterBuilder
The builder instance.
Exceptions
- InvalidOperationException
Thrown if the added field has a ComplexParameterAttribute.
SetParameterType(Type)
Sets ParameterType.
public override SlashCommandParameterBuilder SetParameterType(Type type)
Parameters
type
TypeNew value of the ParameterType.
Returns
- SlashCommandParameterBuilder
The builder instance.
SetParameterType(Type, IServiceProvider)
Sets ParameterType.
public SlashCommandParameterBuilder SetParameterType(Type type, IServiceProvider services = null)
Parameters
type
TypeNew value of the ParameterType.
services
IServiceProviderService container to be used to resolve the dependencies of this parameters TypeConverter.
Returns
- SlashCommandParameterBuilder
The builder instance.
WithAutocompleteHandler(Type, IServiceProvider)
Sets AutocompleteHandler.
public SlashCommandParameterBuilder WithAutocompleteHandler(Type autocompleteHandlerType, IServiceProvider services = null)
Parameters
autocompleteHandlerType
TypeType of the IAutocompleteHandler.
services
IServiceProviderService container to be used to resolve the dependencies of this parameters TypeConverter.
Returns
- SlashCommandParameterBuilder
The builder instance.
WithChannelTypes(params ChannelType[])
Adds channel types to ChannelTypes.
public SlashCommandParameterBuilder WithChannelTypes(params ChannelType[] channelTypes)
Parameters
channelTypes
ChannelType[]New channel types to be added to ChannelTypes.
Returns
- SlashCommandParameterBuilder
The builder instance.
WithChannelTypes(IEnumerable<ChannelType>)
Adds channel types to ChannelTypes.
public SlashCommandParameterBuilder WithChannelTypes(IEnumerable<ChannelType> channelTypes)
Parameters
channelTypes
IEnumerable<ChannelType>New channel types to be added to ChannelTypes.
Returns
- SlashCommandParameterBuilder
The builder instance.
WithChoices(params ParameterChoice[])
Adds parameter choices to Choices.
public SlashCommandParameterBuilder WithChoices(params ParameterChoice[] options)
Parameters
options
ParameterChoice[]New choices to be added to Choices.
Returns
- SlashCommandParameterBuilder
The builder instance.
WithDescription(string)
Sets Description.
public SlashCommandParameterBuilder WithDescription(string description)
Parameters
description
stringNew value of the Description.
Returns
- SlashCommandParameterBuilder
The builder instance.
WithMaxLength(int)
Sets MaxLength.
public SlashCommandParameterBuilder WithMaxLength(int length)
Parameters
Returns
- SlashCommandParameterBuilder
The builder instance.
WithMaxValue(double)
Sets MaxValue.
public SlashCommandParameterBuilder WithMaxValue(double value)
Parameters
Returns
- SlashCommandParameterBuilder
The builder instance.
WithMinLength(int)
Sets MinLength.
public SlashCommandParameterBuilder WithMinLength(int length)
Parameters
Returns
- SlashCommandParameterBuilder
The builder instance.
WithMinValue(double)
Sets MinValue.
public SlashCommandParameterBuilder WithMinValue(double value)
Parameters
Returns
- SlashCommandParameterBuilder
The builder instance.