Class FileUploadComponentBuilder
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Represents a class used to build FileUploadComponent's.
public class FileUploadComponentBuilder : IInteractableComponentBuilder, IMessageComponentBuilder
- Inheritance
-
FileUploadComponentBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
FileUploadComponentBuilder()
Initializes a new instance of the FileUploadComponentBuilder.
public FileUploadComponentBuilder()
FileUploadComponentBuilder(FileUploadComponent)
Initializes a new instance of the FileUploadComponentBuilder class from an existing FileUploadComponent.
public FileUploadComponentBuilder(FileUploadComponent fileUpload)
Parameters
fileUploadFileUploadComponentThe component.
FileUploadComponentBuilder(string, int?, int?, bool, int?, IEnumerable<string>)
Initializes a new instance of the FileUploadComponentBuilder.
public FileUploadComponentBuilder(string customId, int? minValues = null, int? maxValues = null, bool isRequired = true, int? id = null, IEnumerable<string> fileTypes = null)
Parameters
customIdstringThe custom id of the current file upload.
minValuesint?The minimum number of items that must be uploaded (defaults to 1).
maxValuesint?the maximum number of items that can be uploaded (defaults to 1).
isRequiredboolWhether the current file upload requires files to be uploaded before submitting the modal.
idint?The id for the component.
fileTypesIEnumerable<string>The allowed file types.
Fields
MaxFileCount
public const int MaxFileCount = 10
Field Value
MaxFileTypeCount
The maximum number of file types for the FileTypes property.
public const int MaxFileTypeCount = 10
Field Value
Properties
CustomId
Gets or sets the custom id of the current file upload.
public string CustomId { get; set; }
Property Value
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength.
- ArgumentException
CustomId length subceeds 1.
FileTypes
Gets or sets the allowed file types for the current file upload. Can be image, video, audio, or a file extension (e.g. .png).
If no file types are specified, all file types are allowed.
public List<string> FileTypes { get; set; }
Property Value
Id
Gets or sets the id for the component. An autoincremented id will be assigned if not set.
public int? Id { get; set; }
Property Value
- int?
IsRequired
Gets or sets a value indicating whether the current file upload requires files to be uploaded before submitting the modal (defaults to true).
public bool IsRequired { get; set; }
Property Value
MaxValues
Gets or sets the maximum number of items that can be uploaded (defaults to 1).
public int? MaxValues { get; set; }
Property Value
- int?
Exceptions
- ArgumentException
MaxValues exceeds MaxFileCount.
MinValues
Gets or sets the minimum number of items that must be uploaded (defaults to 1).
public int? MinValues { get; set; }
Property Value
- int?
Exceptions
- ArgumentException
MinValues exceeds MaxFileCount.
- ArgumentException
MinValues length subceeds 0.
Type
Gets the type of the component.
public ComponentType Type { get; }
Property Value
Methods
AddFileType(string)
Adds a allowed file type for the current file upload. Can be image, video, audio, or a dot prefixed file extension (e.g. .png).
public FileUploadComponentBuilder AddFileType(string fileType)
Parameters
fileTypestringThe allowed file type.
Returns
- FileUploadComponentBuilder
The current builder.
AddFileTypes(params IEnumerable<string>)
Adds the allowed file types for the current file upload. Can be image, video, audio, or a dot prefixed file extension (e.g. .png).
public FileUploadComponentBuilder AddFileTypes(params IEnumerable<string> fileTypes)
Parameters
fileTypesIEnumerable<string>The allowed file types.
Returns
- FileUploadComponentBuilder
The current builder.
Build()
Runs validation checks and builds the component.
public FileUploadComponent Build()
Returns
WithCustomId(string)
Sets the custom id of the current file upload.
public FileUploadComponentBuilder WithCustomId(string customId)
Parameters
customIdstringThe id to use for the current file upload.
Returns
- FileUploadComponentBuilder
The current builder.
Exceptions
- ArgumentException
CustomId length exceeds MaxCustomIdLength.
- ArgumentException
CustomId length subceeds 1.
WithFileTypes(IEnumerable<string>)
Sets the allowed file types for the current file upload. Can be image, video, audio, or a file extension (e.g. .png).
public FileUploadComponentBuilder WithFileTypes(IEnumerable<string> fileTypes)
Parameters
fileTypesIEnumerable<string>The allowed file types.
Returns
- FileUploadComponentBuilder
The current builder.
WithMaxValues(int?)
Sets the maximum number of items that can be uploaded (defaults to 1).
public FileUploadComponentBuilder WithMaxValues(int? maxValues)
Parameters
maxValuesint?The maximum number of items that can be uploaded.
Returns
- FileUploadComponentBuilder
The current builder.
Exceptions
- ArgumentException
MaxValues exceeds MaxFileCount.
WithMinValues(int?)
Sets the minimum number of items that must be uploaded (defaults to 1).
public FileUploadComponentBuilder WithMinValues(int? minValues)
Parameters
minValuesint?Sets the minimum number of items that must be uploaded.
Returns
- FileUploadComponentBuilder
The current builder.
Exceptions
- ArgumentException
MinValues exceeds MaxFileCount.
- ArgumentException
MinValues length subceeds 0.
WithRequired(bool)
Sets whether the current file upload requires files to be uploaded before submitting the modal.
public FileUploadComponentBuilder WithRequired(bool isRequired)
Parameters
isRequiredboolWhether the current file upload requires files to be uploaded before submitting the modal.
Returns
- FileUploadComponentBuilder
The current builder.