Browse Source

Fix placeholder length being hardcoded (#2421)

* Fix placeholder length being hardcoded

* Add docs for TextInputBuilder.MaxPlaceholderLength
tags/3.8.0
Gutyina Gergő GitHub 2 years ago
parent
commit
8dfe19f328
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs

+ 7
- 3
src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs View File

@@ -1198,6 +1198,10 @@ namespace Discord

public class TextInputBuilder
{
/// <summary>
/// The max length of a <see cref="TextInputComponent.Placeholder"/>.
/// </summary>
public const int MaxPlaceholderLength = 100;
public const int LargestMaxLength = 4000;

/// <summary>
@@ -1229,13 +1233,13 @@ namespace Discord
/// <summary>
/// Gets or sets the placeholder of the current text input.
/// </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
{
get => _placeholder;
set => _placeholder = (value?.Length ?? 0) <= 100
set => _placeholder = (value?.Length ?? 0) <= MaxPlaceholderLength
? value
: throw new ArgumentException("Placeholder cannot have more than 100 characters.");
: throw new ArgumentException($"Placeholder cannot have more than {MaxPlaceholderLength} characters.");
}

/// <summary>


Loading…
Cancel
Save