diff --git a/DisCatSharp/Entities/Interaction/Components/DiscordActionRowComponentResult.cs b/DisCatSharp/Entities/Interaction/Components/DiscordActionRowComponentResult.cs index d6cfe87b6..62d538837 100644 --- a/DisCatSharp/Entities/Interaction/Components/DiscordActionRowComponentResult.cs +++ b/DisCatSharp/Entities/Interaction/Components/DiscordActionRowComponentResult.cs @@ -1,53 +1,53 @@ // 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.Collections.Generic; using DisCatSharp.Enums; using Newtonsoft.Json; namespace DisCatSharp.Entities; /// /// Represents a resolved from a . /// public sealed class DiscordActionRowComponentResult { /// /// The type of component this represents. /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] public ComponentType Type { get; internal set; } /// /// The components contained within the resolved action row. /// [JsonProperty("components", NullValueHandling = NullValueHandling.Ignore)] - public List Components { get; internal set; } + public IReadOnlyList Components { get; internal set; } /// /// Initializes a new instance of the class. /// internal DiscordActionRowComponentResult() { } } diff --git a/DisCatSharp/Entities/Interaction/Components/DiscordComponentResult.cs b/DisCatSharp/Entities/Interaction/Components/DiscordComponentResult.cs index 58c811d5a..abeaf85c5 100644 --- a/DisCatSharp/Entities/Interaction/Components/DiscordComponentResult.cs +++ b/DisCatSharp/Entities/Interaction/Components/DiscordComponentResult.cs @@ -1,65 +1,65 @@ // 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.Collections.Generic; using DisCatSharp.Enums; using Newtonsoft.Json; namespace DisCatSharp.Entities; /// /// Represents a resolved within an . /// public sealed class DiscordComponentResult { /// /// The type of component this represents. /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] public ComponentType Type { get; internal set; } /// /// The Id of this component, if applicable. Not applicable on ActionRow(s) and link buttons. /// [JsonProperty("custom_id", NullValueHandling = NullValueHandling.Ignore)] public string CustomId { get; internal set; } /// - /// The selected value. + /// The users typed value. /// [JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)] public string Value { get; internal set; } /// /// The selected values. Only applicable to Selects. /// [JsonProperty("values", NullValueHandling = NullValueHandling.Ignore)] public IReadOnlyList Values { get; internal set; } /// /// Initializes a new instance of the class. /// internal DiscordComponentResult() { } } diff --git a/DisCatSharp/Entities/Interaction/DiscordInteractionData.cs b/DisCatSharp/Entities/Interaction/DiscordInteractionData.cs index 5a0253225..9298e3231 100644 --- a/DisCatSharp/Entities/Interaction/DiscordInteractionData.cs +++ b/DisCatSharp/Entities/Interaction/DiscordInteractionData.cs @@ -1,93 +1,98 @@ // 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; /// /// Represents the inner data payload of a . /// public sealed class DiscordInteractionData : SnowflakeObject { /// /// Gets the name of the invoked interaction. /// [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] public string Name { get; internal set; } /// /// Gets the parameters and values of the invoked interaction. /// [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)] - public IEnumerable Options { get; internal set; } + public IReadOnlyList Options { get; internal set; } /// - /// Gets the components (Applicable to modal submits). + /// Gets the component rows (Applicable to modal submits). /// [JsonProperty("components", NullValueHandling = NullValueHandling.Ignore)] - public IEnumerable Components { get; internal set; } + internal List ComponentsInternal { get; set; } + + [JsonIgnore] + public IReadOnlyList Components + => this.ComponentsInternal.Select(x => x.Components.First()).ToList(); /// /// Gets the Discord snowflake objects resolved from this interaction's arguments. /// [JsonProperty("resolved", NullValueHandling = NullValueHandling.Ignore)] public DiscordInteractionResolvedCollection Resolved { get; internal set; } /// /// The Id of the component that invoked this interaction, if applicable. /// [JsonProperty("custom_id", NullValueHandling = NullValueHandling.Ignore)] public string CustomId { get; internal set; } /// /// The Id of the target. Applicable for context menus. /// [JsonProperty("target_id", NullValueHandling = NullValueHandling.Ignore)] internal ulong? Target { get; set; } /// /// The type of component that invoked this interaction, if applicable. /// [JsonProperty("component_type", NullValueHandling = NullValueHandling.Ignore)] public ComponentType ComponentType { get; internal set; } /// /// Gets the values of the interaction. /// [JsonProperty("values", NullValueHandling = NullValueHandling.Ignore)] public string[] Values { get; internal set; } = Array.Empty(); /// /// Gets the type of the interaction. /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] public ApplicationCommandType Type { get; internal set; } [JsonProperty("guild_id", NullValueHandling = NullValueHandling.Ignore)] public ulong? GuildId { get; internal set; } }