|
|
@@ -523,6 +523,44 @@ namespace Discord.API |
|
|
|
var ids = new BucketIds(webhookId: webhookId); |
|
|
|
return await SendJsonAsync<Message>("POST", () => $"webhooks/{webhookId}/{AuthToken}?wait=true", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> |
|
|
|
/// <exception cref="InvalidOperationException">This operation may only be called with a <see cref="TokenType.Webhook"/> token.</exception> |
|
|
|
public async Task EditWebhookMessageAsync(ulong webhookId, ulong messageId, EditWebhookMessageParams args, RequestOptions options = null) |
|
|
|
{ |
|
|
|
if (AuthTokenType != TokenType.Webhook) |
|
|
|
throw new InvalidOperationException($"This operation may only be called with a {nameof(TokenType.Webhook)} token."); |
|
|
|
|
|
|
|
Preconditions.NotNull(args, nameof(args)); |
|
|
|
Preconditions.NotEqual(webhookId, 0, nameof(webhookId)); |
|
|
|
Preconditions.NotEqual(messageId, 0, nameof(messageId)); |
|
|
|
if (!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) |
|
|
|
Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); |
|
|
|
|
|
|
|
if (args.Content?.Length > DiscordConfig.MaxMessageSize) |
|
|
|
throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); |
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
var ids = new BucketIds(webhookId: webhookId); |
|
|
|
await SendJsonAsync<Message>("PATCH", () => $"webhooks/{webhookId}/{AuthToken}/messages/{messageId}", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <exception cref="InvalidOperationException">This operation may only be called with a <see cref="TokenType.Webhook"/> token.</exception> |
|
|
|
public async Task DeleteWebhookMessageAsync(ulong webhookId, ulong messageId, RequestOptions options = null) |
|
|
|
{ |
|
|
|
if (AuthTokenType != TokenType.Webhook) |
|
|
|
throw new InvalidOperationException($"This operation may only be called with a {nameof(TokenType.Webhook)} token."); |
|
|
|
|
|
|
|
Preconditions.NotEqual(webhookId, 0, nameof(webhookId)); |
|
|
|
Preconditions.NotEqual(messageId, 0, nameof(messageId)); |
|
|
|
|
|
|
|
options = RequestOptions.CreateOrClone(options); |
|
|
|
|
|
|
|
var ids = new BucketIds(webhookId: webhookId); |
|
|
|
await SendAsync("DELETE", () => $"webhooks/{webhookId}/{AuthToken}/messages/{messageId}", ids, options: options).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception> |
|
|
|
public async Task<Message> UploadFileAsync(ulong channelId, UploadFileParams args, RequestOptions options = null) |
|
|
|
{ |
|
|
|