Files
Discord.Net/src/Discord.Net.Interactions/Attributes/Modals/ModalFileUploadAttribute.cs
Cenk Ergen 9c1db3f0f0 [Fix] Modal Write invocation without instance and missing ChannelTypes (#3221)
* add channel types to channel select builder and info

* add channelTypes to select builder from IModal

* remove public setter requirement from modal component definition and add guard clause to inputs

* refactor modal building to run typeConverter writes even without modal instance

* add inline docs to channelTypes props and method

* add property as a target for ChannelTypesAttribute

* move enum option building logic out of enum typeConverter

* add channel type constraint mapping to channel single-select typeConverter

* move SelectMenuOptionAttribute to its own file

* add null forgiving operator to channel type mapping

* remove list initialization from enum modal typeConverter

* disallow channel default value assignment to mentionable selects

* add id property to modal components

* add component id assignment from attributes

* update component attribute ctor signatures and inline docs

* Update src/Discord.Net.Interactions/TypeConverters/ModalComponents/EnumModalComponentConverter.cs

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>

* replace default values of component ids with 0

---------

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>
2026-01-22 17:50:27 +03:00

35 lines
1.2 KiB
C#

namespace Discord.Interactions;
/// <summary>
/// Marks a <see cref="IModal"/> property as a file upload input.
/// </summary>
public class ModalFileUploadAttribute : ModalInputAttribute
{
/// <inheritdoc/>
public override ComponentType ComponentType => ComponentType.FileUpload;
/// <summary>
/// Get the minimum number of files that can be uploaded.
/// </summary>
public int MinValues { get; set; } = 1;
/// <summary>
/// Get the maximum number of files that can be uploaded.
/// </summary>
public int MaxValues { get; set; } = 1;
/// <summary>
/// Create a new <see cref="ModalFileUploadAttribute"/>.
/// </summary>
/// <param name="customId">Custom ID of the file upload component.</param>
/// <param name="minValues">Minimum number of files that can be uploaded.</param>
/// <param name="maxValues">Maximum number of files that can be uploaded.</param>
/// <param name="id">The optional identifier for the component.</param>
public ModalFileUploadAttribute(string customId, int minValues = 1, int maxValues = 1, int id = 0)
: base(customId, id)
{
MinValues = minValues;
MaxValues = maxValues;
}
}