diff --git a/DisCatSharp/Entities/Interaction/Components/Text/DiscordTextComponent.cs b/DisCatSharp/Entities/Interaction/Components/Text/DiscordTextComponent.cs index 4de11f4e1..4a787fc69 100644 --- a/DisCatSharp/Entities/Interaction/Components/Text/DiscordTextComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Text/DiscordTextComponent.cs @@ -1,108 +1,135 @@ // This file is part of the DisCatSharp project. // // Copyright (c) 2021 AITSYS // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. using DisCatSharp.Enums; using Newtonsoft.Json; namespace DisCatSharp.Entities { /// /// Represents a text component that can be submitted. Fires event when submitted. /// public sealed class DiscordTextComponent : DiscordComponent { /// /// The style of the text component. /// [JsonProperty("style", NullValueHandling = NullValueHandling.Ignore)] public TextComponentStyle Style { get; internal set; } /// - /// The text to apply to the text component. + /// The text description to apply to the text component. /// [JsonProperty("label", NullValueHandling = NullValueHandling.Ignore)] public string Label { get; internal set; } + /// + /// The placeholder for the text component. + /// + [JsonProperty("label", NullValueHandling = NullValueHandling.Ignore)] + public string Placeholder { get; internal set; } + + /// + /// The minimal length of text input. + /// + [JsonProperty("min_length", NullValueHandling = NullValueHandling.Ignore)] + public int? MinLength { get; internal set; } + + /// + /// The maximal length of text input. + /// + [JsonProperty("max_length", NullValueHandling = NullValueHandling.Ignore)] + public int? MaxLength { get; internal set; } + /// /// Whether this text component can be used. /// [JsonProperty("disabled", NullValueHandling = NullValueHandling.Ignore)] public bool Disabled { get; internal set; } /// /// Enables this component if it was disabled before. /// /// The current component. public DiscordTextComponent Enable() { this.Disabled = false; return this; } /// /// Disables this component. /// /// The current component. public DiscordTextComponent Disable() { this.Disabled = true; return this; } /// /// Constructs a new . /// internal DiscordTextComponent() { this.Type = ComponentType.InputText; } /// /// Constucts a new text component based on another text component. /// /// The button to copy. public DiscordTextComponent(DiscordTextComponent other) : this() { this.CustomId = other.CustomId; this.Style = other.Style; this.Label = other.Label; this.Disabled = other.Disabled; + this.MinLength = other.MinLength; + this.MaxLength = other.MaxLength; + this.Placeholder = other.Placeholder; } /// /// Constructs a new text component field with the specified options. /// /// The style of the text component. /// The Id to assign to the text component. This is sent back when a user presses it. /// The text to display before the text component, up to 80 characters. + /// The placeholder for the text input. + /// The minimal length of text input. + /// The maximal length of text input. /// Whether this text component should be initialized as being disabled. - public DiscordTextComponent(TextComponentStyle style, string customId, string label, bool disabled = false) + public DiscordTextComponent(TextComponentStyle style, string customId, string label, string placeholder = null, int? minLength = null, int? maxLength = null, bool disabled = false) { this.Style = style; this.Label = label; this.CustomId = customId; + this.MinLength = minLength; + this.MaxLength = maxLength; + this.Placeholder = placeholder; this.Disabled = disabled; this.Type = ComponentType.InputText; } } }