This reverts commit ba78e0c1f0.
This commit is contained in:
@@ -29,11 +29,6 @@ namespace Discord.Webhook
|
||||
MessageFlags flags, ulong? threadId = null, string threadName = null, ulong[] appliedTags = null,
|
||||
PollProperties poll = null)
|
||||
{
|
||||
if (components?.Components.Any(x => x.Type is not ComponentType.ActionRow) ?? false)
|
||||
flags |= MessageFlags.ComponentsV2;
|
||||
|
||||
Preconditions.ValidateMessageFlags(flags);
|
||||
|
||||
var args = new CreateWebhookMessageParams
|
||||
{
|
||||
Content = text,
|
||||
@@ -53,7 +48,7 @@ namespace Discord.Webhook
|
||||
if (allowedMentions != null)
|
||||
args.AllowedMentions = allowedMentions.ToModel();
|
||||
if (components != null)
|
||||
args.Components = components?.Components.Select(x => x.ToModel()).ToArray();
|
||||
args.Components = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray();
|
||||
if (threadName is not null)
|
||||
args.ThreadName = threadName;
|
||||
if (appliedTags != null)
|
||||
@@ -61,6 +56,8 @@ namespace Discord.Webhook
|
||||
if (poll != null)
|
||||
args.Poll = poll.ToModel();
|
||||
|
||||
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds and not MessageFlags.SuppressNotification)
|
||||
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds, SuppressNotification and none.", nameof(flags));
|
||||
|
||||
var model = await client.ApiClient.CreateWebhookMessageAsync(client.Webhook.Id, args, options: options, threadId: threadId).ConfigureAwait(false);
|
||||
return model.Id;
|
||||
@@ -111,14 +108,14 @@ namespace Discord.Webhook
|
||||
AllowedMentions = args.AllowedMentions.IsSpecified
|
||||
? args.AllowedMentions.Value.ToModel()
|
||||
: Optional.Create<API.AllowedMentions>(),
|
||||
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() : Optional<IMessageComponent[]>.Unspecified,
|
||||
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||
};
|
||||
|
||||
return client.ApiClient.ModifyWebhookMessageAsync(client.Webhook.Id, messageId, apiArgs, options, threadId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var attachments = args.Attachments.Value?.ToArray() ?? [];
|
||||
var attachments = args.Attachments.Value?.ToArray() ?? Array.Empty<FileAttachment>();
|
||||
|
||||
var apiArgs = new UploadWebhookFileParams(attachments)
|
||||
{
|
||||
@@ -130,7 +127,7 @@ namespace Discord.Webhook
|
||||
AllowedMentions = args.AllowedMentions.IsSpecified
|
||||
? args.AllowedMentions.Value.ToModel()
|
||||
: Optional.Create<API.AllowedMentions>(),
|
||||
MessageComponents = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => x.ToModel()).ToArray() : Optional<IMessageComponent[]>.Unspecified,
|
||||
MessageComponents = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified,
|
||||
};
|
||||
|
||||
return client.ApiClient.ModifyWebhookMessageAsync(client.Webhook.Id, messageId, apiArgs, options, threadId);
|
||||
@@ -196,10 +193,8 @@ namespace Discord.Webhook
|
||||
}
|
||||
}
|
||||
|
||||
if (components?.Components.Any(x => x.Type is not ComponentType.ActionRow) ?? false)
|
||||
flags |= MessageFlags.ComponentsV2;
|
||||
|
||||
Preconditions.ValidateMessageFlags(flags);
|
||||
if (flags is not MessageFlags.None and not MessageFlags.SuppressEmbeds and not MessageFlags.SuppressNotification)
|
||||
throw new ArgumentException("The only valid MessageFlags are SuppressEmbeds, SuppressNotification and none.", nameof(flags));
|
||||
|
||||
var args = new UploadWebhookFileParams(attachments.ToArray())
|
||||
{
|
||||
@@ -209,7 +204,7 @@ namespace Discord.Webhook
|
||||
IsTTS = isTTS,
|
||||
Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional<API.Embed[]>.Unspecified,
|
||||
AllowedMentions = allowedMentions?.ToModel() ?? Optional<API.AllowedMentions>.Unspecified,
|
||||
MessageComponents = components?.Components.Select(x => x.ToModel()).ToArray() ?? Optional<IMessageComponent[]>.Unspecified,
|
||||
MessageComponents = components?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional<API.ActionRowComponent[]>.Unspecified,
|
||||
Flags = flags,
|
||||
ThreadName = threadName,
|
||||
AppliedTags = appliedTags,
|
||||
|
||||
Reference in New Issue
Block a user