From fce77ee0a0a39d1af6095692df5d1ee5d939ccf5 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Wed, 20 Sep 2023 23:03:24 +0200 Subject: [PATCH 1/4] feat: default values for select menus --- .../Select/DiscordBaseSelectComponent.cs | 41 ++++++++- .../Select/DiscordChannelSelectComponent.cs | 12 +-- .../DiscordMentionableSelectComponent.cs | 13 ++- .../Select/DiscordRoleSelectComponent.cs | 12 ++- .../Select/DiscordSelectDefaultValue.cs | 86 +++++++++++++++++++ .../Select/DiscordUserSelectComponent.cs | 12 ++- 6 files changed, 157 insertions(+), 19 deletions(-) create mode 100644 DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs index 22b1dae51..80783805f 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using DisCatSharp.Enums; @@ -41,6 +43,11 @@ public class DiscordBaseSelectComponent : DiscordComponent [JsonProperty("label", NullValueHandling = NullValueHandling.Ignore)] public string Label { get; internal set; } = null; + /// + /// The default values of this select menu. + /// + [JsonProperty("default_values", NullValueHandling = NullValueHandling.Ignore)] + public List? DefaultValues { get; internal set; } = null; /// /// Constructs a new . @@ -51,7 +58,8 @@ public class DiscordBaseSelectComponent : DiscordComponent /// 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. - internal DiscordBaseSelectComponent(ComponentType type, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) + /// The default values of this select menu. Not valid for . + internal DiscordBaseSelectComponent(ComponentType type, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) { this.Type = type; this.CustomId = customId ?? Guid.NewGuid().ToString(); ; @@ -59,6 +67,20 @@ internal DiscordBaseSelectComponent(ComponentType type, string placeholder, stri this.Placeholder = placeholder; this.MinimumSelectedValues = minOptions; this.MaximumSelectedValues = maxOptions; + if (defaultValues is not null) + { + if (defaultValues.Count() > maxOptions) + throw new OverflowException("The amount of default values cannot exceed the maximum amount of selectable options."); + if (type == ComponentType.MentionableSelect && defaultValues.Any(x => x.Type == "channel")) + throw new ArgumentException("The default values for a mentionable select must be of type user or role.", nameof(defaultValues)); + if (type == ComponentType.ChannelSelect && defaultValues.Any(x => x.Type == "channel")) + throw new ArgumentException("The default values for a channel select menus must be of type channel.", nameof(defaultValues)); + if (type == ComponentType.UserSelect && defaultValues.Any(x => x.Type != "user")) + throw new ArgumentException("The default values for a user select menus must be of type user.", nameof(defaultValues)); + if (type == ComponentType.RoleSelect && defaultValues.Any(x => x.Type != "role")) + throw new ArgumentException("The default values for a role select menus must be of type role.", nameof(defaultValues)); + } + this.DefaultValues = defaultValues?.ToList(); } /// @@ -71,7 +93,8 @@ internal DiscordBaseSelectComponent(ComponentType type, string placeholder, stri /// 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. - internal DiscordBaseSelectComponent(ComponentType type, string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) + /// The default values of this select menu. Not valid for . + internal DiscordBaseSelectComponent(ComponentType type, string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) { this.Type = type; this.Label = label; @@ -80,6 +103,20 @@ internal DiscordBaseSelectComponent(ComponentType type, string label, string pla this.Placeholder = placeholder; this.MinimumSelectedValues = minOptions; this.MaximumSelectedValues = maxOptions; + if (defaultValues is not null) + { + if (defaultValues.Count() > maxOptions) + throw new OverflowException("The amount of default values cannot exceed the maximum amount of selectable options."); + if (type == ComponentType.MentionableSelect && defaultValues.Any(x => x.Type == "channel")) + throw new ArgumentException("The default values for a mentionable select must be of type user or role.", nameof(defaultValues)); + if (type == ComponentType.ChannelSelect && defaultValues.Any(x => x.Type == "channel")) + throw new ArgumentException("The default values for a channel select menus must be of type channel.", nameof(defaultValues)); + if (type == ComponentType.UserSelect && defaultValues.Any(x => x.Type != "user")) + throw new ArgumentException("The default values for a user select menus must be of type user.", nameof(defaultValues)); + if (type == ComponentType.RoleSelect && defaultValues.Any(x => x.Type != "role")) + throw new ArgumentException("The default values for a role select menus must be of type role.", nameof(defaultValues)); + } + this.DefaultValues = defaultValues?.ToList(); } internal DiscordBaseSelectComponent() diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs index ef57ef3cd..050ebc840 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordChannelSelectComponent.cs @@ -17,7 +17,7 @@ public sealed class DiscordChannelSelectComponent : DiscordBaseSelectComponent /// The channel types to filter by. /// [JsonProperty("channel_types", NullValueHandling = NullValueHandling.Ignore)] - public IReadOnlyList ChannelTypes { get; internal set; } = null; + public IReadOnlyList? ChannelTypes { get; internal set; } = null; /// /// Enables this component if it was disabled before. @@ -50,8 +50,9 @@ public DiscordChannelSelectComponent Disable() /// 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, IEnumerable channelTypes = null, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.ChannelSelect, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordChannelSelectComponent(string placeholder, IEnumerable channelTypes = null, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.ChannelSelect, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { this.ChannelTypes = channelTypes?.ToArray() ?? Array.Empty(); } @@ -66,8 +67,9 @@ public DiscordChannelSelectComponent(string placeholder, IEnumerableMinimum 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, IEnumerable channelTypes = null, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.ChannelSelect, label, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordChannelSelectComponent(string label, string placeholder, IEnumerable channelTypes = null, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.ChannelSelect, label, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { this.ChannelTypes = channelTypes?.ToArray() ?? Array.Empty(); } diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordMentionableSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordMentionableSelectComponent.cs index de199a427..518ddded4 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordMentionableSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordMentionableSelectComponent.cs @@ -20,6 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Collections.Generic; +using System.Linq; + using DisCatSharp.Enums; namespace DisCatSharp.Entities; @@ -59,8 +62,9 @@ public DiscordMentionableSelectComponent Disable() /// 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 DiscordMentionableSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.MentionableSelect, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordMentionableSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.MentionableSelect, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { } /// @@ -72,8 +76,9 @@ public DiscordMentionableSelectComponent(string placeholder, string customId = n /// 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 DiscordMentionableSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.MentionableSelect, label, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordMentionableSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.MentionableSelect, label, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { } /// diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordRoleSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordRoleSelectComponent.cs index 08142ec48..44f62ecca 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordRoleSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordRoleSelectComponent.cs @@ -20,6 +20,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Collections.Generic; + using DisCatSharp.Enums; namespace DisCatSharp.Entities; @@ -59,8 +61,9 @@ public DiscordRoleSelectComponent Disable() /// 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 DiscordRoleSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.RoleSelect, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordRoleSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.RoleSelect, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { } /// @@ -72,8 +75,9 @@ public DiscordRoleSelectComponent(string placeholder, string customId = null, in /// 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 DiscordRoleSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.RoleSelect, label, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordRoleSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.RoleSelect, label, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { } /// diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs new file mode 100644 index 000000000..9f2369c07 --- /dev/null +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs @@ -0,0 +1,86 @@ +// This file is part of the DisCatSharp project, based off DSharpPlus. +// +// Copyright (c) 2021-2023 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 NON-INFRINGEMENT. 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 DisCatSharp.Enums; + +using Newtonsoft.Json; + +namespace DisCatSharp.Entities; + +/// +/// A select default value for use with , , or . +/// +public sealed class DiscordSelectDefaultValue +{ + /// + /// The id of a user, role, or channel. + /// + [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] + public ulong Id { get; internal set; } + + /// + /// The type of value that represents. + /// + [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] + public string Type { get; internal set; } + + /// + /// Constructs a new for an with corrosponding . + /// + /// The id to set. + /// The type of the . Can be user, role or channel + public DiscordSelectDefaultValue(ulong id, string type) + { + this.Id = id; + this.Type = type; + } + + /// + /// Constructs a new for a role. + /// + /// The role to set. + public DiscordSelectDefaultValue(DiscordRole role) + { + this.Id = role.Id; + this.Type = "role"; + } + + /// + /// Constructs a new for a user. + /// + /// The user to set. + public DiscordSelectDefaultValue(DiscordUser user) + { + this.Id = user.Id; + this.Type = "user"; + } + + /// + /// Constructs a new for a channel. + /// + /// The channel to set. + public DiscordSelectDefaultValue(DiscordChannel channel) + { + this.Id = channel.Id; + this.Type = "channel"; + } +} diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordUserSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordUserSelectComponent.cs index 772dbf89b..eb4a66086 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordUserSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordUserSelectComponent.cs @@ -20,6 +20,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Collections.Generic; + using DisCatSharp.Enums; namespace DisCatSharp.Entities; @@ -57,8 +59,9 @@ public DiscordUserSelectComponent Disable() /// 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 DiscordUserSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.UserSelect, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordUserSelectComponent(string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.UserSelect, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { } /// @@ -70,8 +73,9 @@ public DiscordUserSelectComponent(string placeholder, string customId = null, in /// 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 DiscordUserSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false) - : base(ComponentType.UserSelect, label, placeholder, customId, minOptions, maxOptions, disabled) + /// The default values of this select menu. + public DiscordUserSelectComponent(string label, string placeholder, string customId = null, int minOptions = 1, int maxOptions = 1, bool disabled = false, IEnumerable? defaultValues = null) + : base(ComponentType.UserSelect, label, placeholder, customId, minOptions, maxOptions, disabled, defaultValues) { } /// From ab6c73d4a205d66c5342c0247b654725663d3941 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Thu, 21 Sep 2023 00:53:15 +0200 Subject: [PATCH 2/4] chore(deps): bump dotnet --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/documentation.yml | 2 +- .github/workflows/documentation_test.yml | 2 +- .github/workflows/internal-release.yml | 2 +- .github/workflows/release.yml | 2 +- DisCatSharp.ApplicationCommands/global.json | 2 +- DisCatSharp.Attributes/global.json | 2 +- DisCatSharp.CommandsNext/global.json | 2 +- DisCatSharp.Common/global.json | 2 +- DisCatSharp.Configuration.Tests/global.json | 2 +- DisCatSharp.Configuration/global.json | 2 +- DisCatSharp.EventHandlers.Tests/global.json | 2 +- DisCatSharp.Experimental/global.json | 2 +- DisCatSharp.Hosting.DependencyInjection/global.json | 2 +- DisCatSharp.Hosting.Tests/global.json | 2 +- DisCatSharp.Hosting/global.json | 2 +- DisCatSharp.Interactivity/global.json | 2 +- DisCatSharp.LavalinkV1/global.json | 2 +- DisCatSharp.VoiceNext.Natives/global.json | 2 +- DisCatSharp.VoiceNext/global.json | 2 +- DisCatSharp/global.json | 2 +- global.json | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 886572028..2c6ce5e4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-dotnet@v3.2.0 with: dotnet-version: | - 7.0.400 + 7.0.401 6.x - name: Build library run: dotnet build -c Release -v minimal DisCatSharp.sln diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 01d3e0f5d..d6a82e84d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,7 +33,7 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: | - 7.0.400 + 7.0.401 6.x - name: Build run: | diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 3de080502..dbac46cb4 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -21,7 +21,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: 7.0.400 + dotnet-version: 7.0.401 - name: Git fetch unshallow run: git fetch --unshallow - name: Install DocFX diff --git a/.github/workflows/documentation_test.yml b/.github/workflows/documentation_test.yml index aba687578..d396418d4 100644 --- a/.github/workflows/documentation_test.yml +++ b/.github/workflows/documentation_test.yml @@ -22,7 +22,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: 7.0.400 + dotnet-version: 7.0.401 - name: Install DocFX run: dotnet tool update -g docfx --prerelease continue-on-error: true diff --git a/.github/workflows/internal-release.yml b/.github/workflows/internal-release.yml index bafd10d09..b74c4d6cd 100644 --- a/.github/workflows/internal-release.yml +++ b/.github/workflows/internal-release.yml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-dotnet@v3.2.0 with: dotnet-version: | - 7.0.400 + 7.0.401 6.x - name: Restore dependencies run: dotnet restore DisCatSharp.sln diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8c266392..df9873f22 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: uses: actions/setup-dotnet@v3.2.0 with: dotnet-version: | - 7.0.400 + 7.0.401 6.x - name: Restore dependencies run: dotnet restore DisCatSharp.sln diff --git a/DisCatSharp.ApplicationCommands/global.json b/DisCatSharp.ApplicationCommands/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.ApplicationCommands/global.json +++ b/DisCatSharp.ApplicationCommands/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Attributes/global.json b/DisCatSharp.Attributes/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Attributes/global.json +++ b/DisCatSharp.Attributes/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.CommandsNext/global.json b/DisCatSharp.CommandsNext/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.CommandsNext/global.json +++ b/DisCatSharp.CommandsNext/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Common/global.json b/DisCatSharp.Common/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Common/global.json +++ b/DisCatSharp.Common/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Configuration.Tests/global.json b/DisCatSharp.Configuration.Tests/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Configuration.Tests/global.json +++ b/DisCatSharp.Configuration.Tests/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Configuration/global.json b/DisCatSharp.Configuration/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Configuration/global.json +++ b/DisCatSharp.Configuration/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.EventHandlers.Tests/global.json b/DisCatSharp.EventHandlers.Tests/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.EventHandlers.Tests/global.json +++ b/DisCatSharp.EventHandlers.Tests/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Experimental/global.json b/DisCatSharp.Experimental/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Experimental/global.json +++ b/DisCatSharp.Experimental/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Hosting.DependencyInjection/global.json b/DisCatSharp.Hosting.DependencyInjection/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Hosting.DependencyInjection/global.json +++ b/DisCatSharp.Hosting.DependencyInjection/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Hosting.Tests/global.json b/DisCatSharp.Hosting.Tests/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Hosting.Tests/global.json +++ b/DisCatSharp.Hosting.Tests/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Hosting/global.json b/DisCatSharp.Hosting/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Hosting/global.json +++ b/DisCatSharp.Hosting/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.Interactivity/global.json b/DisCatSharp.Interactivity/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.Interactivity/global.json +++ b/DisCatSharp.Interactivity/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.LavalinkV1/global.json b/DisCatSharp.LavalinkV1/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.LavalinkV1/global.json +++ b/DisCatSharp.LavalinkV1/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.VoiceNext.Natives/global.json b/DisCatSharp.VoiceNext.Natives/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.VoiceNext.Natives/global.json +++ b/DisCatSharp.VoiceNext.Natives/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp.VoiceNext/global.json b/DisCatSharp.VoiceNext/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp.VoiceNext/global.json +++ b/DisCatSharp.VoiceNext/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/DisCatSharp/global.json b/DisCatSharp/global.json index 07e33882c..e91a1528e 100644 --- a/DisCatSharp/global.json +++ b/DisCatSharp/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } diff --git a/global.json b/global.json index 07e33882c..e91a1528e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.400", + "version": "7.0.401", "rollForward": "latestMinor" } } From 57e71e9c8b2ee1d184aec1e1bc90899cff3ce498 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Thu, 21 Sep 2023 09:17:04 +0200 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20!=3D=20not=20=3D=3D=20=F0=9F=A4=A6?= =?UTF-8?q?=E2=80=8D=E2=99=80=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lala Sabathil --- .../Components/Select/DiscordBaseSelectComponent.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs index 80783805f..66654d2de 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordBaseSelectComponent.cs @@ -73,7 +73,7 @@ internal DiscordBaseSelectComponent(ComponentType type, string placeholder, stri throw new OverflowException("The amount of default values cannot exceed the maximum amount of selectable options."); if (type == ComponentType.MentionableSelect && defaultValues.Any(x => x.Type == "channel")) throw new ArgumentException("The default values for a mentionable select must be of type user or role.", nameof(defaultValues)); - if (type == ComponentType.ChannelSelect && defaultValues.Any(x => x.Type == "channel")) + if (type == ComponentType.ChannelSelect && defaultValues.Any(x => x.Type != "channel")) throw new ArgumentException("The default values for a channel select menus must be of type channel.", nameof(defaultValues)); if (type == ComponentType.UserSelect && defaultValues.Any(x => x.Type != "user")) throw new ArgumentException("The default values for a user select menus must be of type user.", nameof(defaultValues)); @@ -109,7 +109,7 @@ internal DiscordBaseSelectComponent(ComponentType type, string label, string pla throw new OverflowException("The amount of default values cannot exceed the maximum amount of selectable options."); if (type == ComponentType.MentionableSelect && defaultValues.Any(x => x.Type == "channel")) throw new ArgumentException("The default values for a mentionable select must be of type user or role.", nameof(defaultValues)); - if (type == ComponentType.ChannelSelect && defaultValues.Any(x => x.Type == "channel")) + if (type == ComponentType.ChannelSelect && defaultValues.Any(x => x.Type != "channel")) throw new ArgumentException("The default values for a channel select menus must be of type channel.", nameof(defaultValues)); if (type == ComponentType.UserSelect && defaultValues.Any(x => x.Type != "user")) throw new ArgumentException("The default values for a user select menus must be of type user.", nameof(defaultValues)); From 3f8aed6026b231a8e515aa47c39b157dfe03549d Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Thu, 21 Sep 2023 09:29:33 +0200 Subject: [PATCH 4/4] fix: json screams Signed-off-by: Lala Sabathil --- .../Select/DiscordSelectDefaultValue.cs | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs b/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs index 9f2369c07..95d6fd5d6 100644 --- a/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs +++ b/DisCatSharp/Entities/Interaction/Components/Select/DiscordSelectDefaultValue.cs @@ -1,25 +1,3 @@ -// This file is part of the DisCatSharp project, based off DSharpPlus. -// -// Copyright (c) 2021-2023 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 NON-INFRINGEMENT. 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 DisCatSharp.Enums; using Newtonsoft.Json; @@ -83,4 +61,11 @@ public DiscordSelectDefaultValue(DiscordChannel channel) this.Id = channel.Id; this.Type = "channel"; } + + /// + /// Constructs a new for a channel. + /// + internal DiscordSelectDefaultValue() + { + } }