From 35b493c11c6cd68fc5488378ee200e55bccdbee4 Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Sat, 24 May 2025 22:28:35 +0300 Subject: [PATCH] Fix some CV2 oversights (#3135) --- src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs | 6 ++++-- .../Entities/Interactions/InteractionHelper.cs | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs index 29be16cb..130270a0 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ThreadHelper.cs @@ -146,12 +146,14 @@ namespace Discord.Rest Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed."); } - if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds) - throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds and none.", nameof(flags)); + if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false) + flags |= MessageFlags.ComponentsV2; + Preconditions.ValidateMessageFlags(flags); if (channel.Flags.HasFlag(ChannelFlags.RequireTag)) Preconditions.AtLeast(tagIds?.Length ?? 0, 1, nameof(tagIds), $"The channel {channel.Name} requires posts to have at least one tag."); + var args = new CreatePostParams() { Title = title, diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index ce07a294..77dd0523 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -432,6 +432,7 @@ namespace Discord.Rest Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional.Unspecified, + Flags = args.Flags }; return client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options); @@ -494,7 +495,10 @@ namespace Discord.Rest Embeds = apiEmbeds?.ToArray() ?? Optional.Unspecified, AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional.Unspecified, MessageComponents = args.Components.IsSpecified - ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional.Unspecified + ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional.Unspecified, + Flags = args.Flags.IsSpecified + ? (args.Flags.Value ?? Optional.Unspecified) + : Optional.Unspecified }; return client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options);