Fix some CV2 oversights (#3135)

This commit is contained in:
Mihail Gribkov
2025-05-24 22:28:35 +03:00
committed by GitHub
parent e68fa50797
commit 35b493c11c
2 changed files with 9 additions and 3 deletions

View File

@@ -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,

View File

@@ -432,6 +432,7 @@ namespace Discord.Rest
Components = args.Components.IsSpecified
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
: Optional<IMessageComponent[]>.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<API.Embed[]>.Unspecified,
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
MessageComponents = args.Components.IsSpecified
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional<IMessageComponent[]>.Unspecified
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? [] : Optional<IMessageComponent[]>.Unspecified,
Flags = args.Flags.IsSpecified
? (args.Flags.Value ?? Optional<MessageFlags>.Unspecified)
: Optional<MessageFlags>.Unspecified
};
return client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options);