diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectComponent.cs
index 6e4ad6cef..754faeee7 100644
--- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectComponent.cs
+++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectComponent.cs
@@ -1,116 +1,143 @@
// This file is part of the DisCatSharp project, based off DSharpPlus.
//
// Copyright (c) 2021-2022 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 System;
using System.Collections.Generic;
using System.Linq;
using DisCatSharp.Enums;
using Newtonsoft.Json;
namespace DisCatSharp.Entities;
///
/// A select menu with multiple options to choose from.
///
public sealed class DiscordSelectComponent : DiscordComponent
{
///
/// The options to pick from on this component.
///
[JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
public IReadOnlyList Options { get; internal set; } = Array.Empty();
///
/// The text to show when no option is selected.
///
[JsonProperty("placeholder", NullValueHandling = NullValueHandling.Ignore)]
public string Placeholder { get; internal set; }
///
/// The minimum amount of options that can be selected. Must be less than or equal to . Defaults to one.
///
[JsonProperty("min_values", NullValueHandling = NullValueHandling.Ignore)]
public int? MinimumSelectedValues { get; internal set; } = 1;
///
/// The maximum amount of options that can be selected. Must be greater than or equal to zero or . Defaults to one.
///
[JsonProperty("max_values", NullValueHandling = NullValueHandling.Ignore)]
public int? MaximumSelectedValues { get; internal set; } = 1;
///
/// Whether this select can be used.
///
[JsonProperty("disabled", NullValueHandling = NullValueHandling.Ignore)]
public bool Disabled { get; internal set; }
+ ///
+ /// Label of component, if used in modal.
+ ///
+ [JsonProperty("label", NullValueHandling = NullValueHandling.Ignore)]
+ public string Label { get; internal set; } = null;
+
///
/// Enables this component if it was disabled before.
///
/// The current component.
public DiscordSelectComponent Enable()
{
this.Disabled = false;
return this;
}
///
/// Disables this component.
///
/// The current component.
public DiscordSelectComponent Disable()
{
this.Disabled = true;
return this;
}
// TODO: Can we set required
///
/// Constructs a new .
///
- /// The Id to assign to the button. This is sent back when a user presses it.
- /// Array of options
/// Text to show if no option is selected.
+ /// Array of options
+ /// The Id to assign to the select component.
/// Minimum count of selectable options.
/// Maximum count of selectable options.
- /// Whether this button should be initialized as being disabled. User sees a greyed out button that cannot be interacted with.
+ /// Whether this select component should be initialized as being disabled. User sees a greyed out select component that cannot be interacted with.
public DiscordSelectComponent(string placeholder, IEnumerable options, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) : this()
{
this.CustomId = customId ?? Guid.NewGuid().ToString(); ;
this.Disabled = disabled;
this.Options = options.ToArray();
this.Placeholder = placeholder;
this.MinimumSelectedValues = minOptions;
this.MaximumSelectedValues = maxOptions;
}
+ ///
+ /// Constructs a new for modals.
+ ///
+ /// Maximum count of selectable options.
+ /// Text to show if no option is selected.
+ /// Array of options
+ /// The Id to assign to the select component.
+ /// Minimum count of selectable options.
+ /// Maximum count of selectable options.
+ /// Whether this select component should be initialized as being disabled. User sees a greyed out select component that cannot be interacted with.
+ public DiscordSelectComponent(string label, string placeholder, IEnumerable options, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) : this()
+ {
+ this.Label = label;
+ this.CustomId = customId ?? Guid.NewGuid().ToString(); ;
+ this.Disabled = disabled;
+ this.Options = options.ToArray();
+ this.Placeholder = placeholder;
+ this.MinimumSelectedValues = minOptions;
+ this.MaximumSelectedValues = maxOptions;
+ }
+
///
/// Initializes a new instance of the class.
///
public DiscordSelectComponent()
{
this.Type = ComponentType.Select;
}
}