diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs index 785e6dc1b..d01d7d271 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs @@ -1,133 +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 DiscordChannelSelectComponent : DiscordComponent { /// /// The text to show when no option is selected. /// [JsonProperty("placeholder", NullValueHandling = NullValueHandling.Ignore)] public string Placeholder { get; internal set; } + /// + /// The channel types to filter by. + /// + [JsonProperty("channel_types", NullValueHandling = NullValueHandling.Ignore)] + public IReadOnlyList ChannelTypes { get; internal set; } = null; + /// /// 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 DiscordChannelSelectComponent Enable() { this.Disabled = false; return this; } /// /// Disables this component. /// /// The current component. public DiscordChannelSelectComponent Disable() { this.Disabled = true; return this; } // TODO: Can we set required /// /// Constructs a new . /// /// Text to show if no option is selected. + /// The channel types to filter by. /// 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 DiscordChannelSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) : this() + public DiscordChannelSelectComponent(string placeholder, IEnumerable channelTypes = null, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) : this() { this.CustomId = customId ?? Guid.NewGuid().ToString(); ; this.Disabled = disabled; this.Placeholder = placeholder; + this.ChannelTypes = channelTypes.ToList().AsReadOnly(); this.MinimumSelectedValues = minOptions; this.MaximumSelectedValues = maxOptions; } /// /// Constructs a new for modals. /// /// Maximum count of selectable options. /// Text to show if no option is selected. + /// The channel types to filter by. /// 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 DiscordChannelSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) : this() + public DiscordChannelSelectComponent(string label, string placeholder, IEnumerable channelTypes = null, 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.Placeholder = placeholder; + this.ChannelTypes = channelTypes.ToList().AsReadOnly(); this.MinimumSelectedValues = minOptions; this.MaximumSelectedValues = maxOptions; } /// /// Initializes a new instance of the class. /// public DiscordChannelSelectComponent() { this.Type = ComponentType.ChannelSelect; } }