Fix placeholder length being hardcoded (#2421)
* Fix placeholder length being hardcoded * Add docs for TextInputBuilder.MaxPlaceholderLength
This commit is contained in:
@@ -1198,6 +1198,10 @@ namespace Discord
|
|||||||
|
|
||||||
public class TextInputBuilder
|
public class TextInputBuilder
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The max length of a <see cref="TextInputComponent.Placeholder"/>.
|
||||||
|
/// </summary>
|
||||||
|
public const int MaxPlaceholderLength = 100;
|
||||||
public const int LargestMaxLength = 4000;
|
public const int LargestMaxLength = 4000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1229,13 +1233,13 @@ namespace Discord
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the placeholder of the current text input.
|
/// Gets or sets the placeholder of the current text input.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ArgumentException"><see cref="Placeholder"/> is longer than 100 characters</exception>
|
/// <exception cref="ArgumentException"><see cref="Placeholder"/> is longer than <see cref="MaxPlaceholderLength"/> characters</exception>
|
||||||
public string Placeholder
|
public string Placeholder
|
||||||
{
|
{
|
||||||
get => _placeholder;
|
get => _placeholder;
|
||||||
set => _placeholder = (value?.Length ?? 0) <= 100
|
set => _placeholder = (value?.Length ?? 0) <= MaxPlaceholderLength
|
||||||
? value
|
? value
|
||||||
: throw new ArgumentException("Placeholder cannot have more than 100 characters.");
|
: throw new ArgumentException($"Placeholder cannot have more than {MaxPlaceholderLength} characters.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user