Fix some CV2 oversights (#3135)
This commit is contained in:
@@ -146,12 +146,14 @@ namespace Discord.Rest
|
|||||||
Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed.");
|
Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds)
|
if (components?.Components?.Any(x => x.Type != ComponentType.ActionRow) ?? false)
|
||||||
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds and none.", nameof(flags));
|
flags |= MessageFlags.ComponentsV2;
|
||||||
|
Preconditions.ValidateMessageFlags(flags);
|
||||||
|
|
||||||
if (channel.Flags.HasFlag(ChannelFlags.RequireTag))
|
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.");
|
Preconditions.AtLeast(tagIds?.Length ?? 0, 1, nameof(tagIds), $"The channel {channel.Name} requires posts to have at least one tag.");
|
||||||
|
|
||||||
|
|
||||||
var args = new CreatePostParams()
|
var args = new CreatePostParams()
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
|
|||||||
@@ -432,6 +432,7 @@ namespace Discord.Rest
|
|||||||
Components = args.Components.IsSpecified
|
Components = args.Components.IsSpecified
|
||||||
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() ?? []
|
||||||
: Optional<IMessageComponent[]>.Unspecified,
|
: Optional<IMessageComponent[]>.Unspecified,
|
||||||
|
Flags = args.Flags
|
||||||
};
|
};
|
||||||
|
|
||||||
return client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options);
|
return client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options);
|
||||||
@@ -494,7 +495,10 @@ namespace Discord.Rest
|
|||||||
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
Embeds = apiEmbeds?.ToArray() ?? Optional<API.Embed[]>.Unspecified,
|
||||||
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value?.ToModel() : Optional<API.AllowedMentions>.Unspecified,
|
||||||
MessageComponents = args.Components.IsSpecified
|
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);
|
return client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user