Class WebhookClient
A specialized client that can be used to interact with webhook endpoints.
public sealed class WebhookClient : IDisposable
- Inheritance
-
WebhookClient
- Implements
- Inherited Members
Constructors
WebhookClient(ulong, string, WebhookClientConfiguration?)
Creates a WebhookClient from its ID, token, and optional configuration.
public WebhookClient(ulong webhookId, string webhookToken, WebhookClientConfiguration? configuration = null)
Parameters
webhookIdulongThe ID of the webhook to use. webhookTokenstringThe token to use for authorization. configurationWebhookClientConfigurationThe configuration to pass to the client.
Properties
Id
The ID of the webhook to use.
public ulong Id { get; }
Property Value
Token
The token to use for authorization.
public string Token { get; }
Property Value
Methods
DeleteAsync(RestRequestProperties?, CancellationToken)
Deletes a webhook permanently, using the specified token.
public Task DeleteAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
Remarks
Requires the ManageWebhooks permission, and fires a WebhooksUpdate event.
DeleteMessageAsync(ulong, ulong?, RestRequestProperties?, CancellationToken)
Deletes a previously-sent webhook message permanently.
public Task DeleteMessageAsync(ulong messageId, ulong? threadId = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to delete.
threadIdulong?The ID of the thread the message is in.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
Dispose()
public void Dispose()
ExecuteAsync(WebhookMessageProperties, bool, ulong?, bool, RestRequestProperties?, CancellationToken)
Executes a webhook with the given parameters, optionally returning the message result.
public Task<RestMessage?> ExecuteAsync(WebhookMessageProperties message, bool wait = false, ulong? threadId = null, bool withComponents = true, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageWebhookMessagePropertiesThe message to send through the webhook.
waitboolIf set, the returned RestMessage will contain the sent message, otherwise null.
threadIdulong?Optional ID of the thread to send the message in, within the webhook's target channel. Can be null.
withComponentsboolWhether to respect the
message's Components.When enabled, allows application-owned webhooks to use all components, and non-owned webhooks to use non-interactive components.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
GetAsync(RestRequestProperties?, CancellationToken)
Retrieves a Webhook object for the given ID, using the specified webhook token.
public Task<Webhook> GetAsync(RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
Remarks
This endpoint does not require authentication.
GetMessageAsync(ulong, ulong?, RestRequestProperties?, CancellationToken)
Returns a previously-sent webhook message.
public Task<RestMessage> GetMessageAsync(ulong messageId, ulong? threadId = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to retrieve.
threadIdulong?The ID of the thread the message is in.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
ModifyAsync(Action<WebhookOptions>, RestRequestProperties?, CancellationToken)
Modifies a webhook using the specified token, returning the updated Webhook object on success.
public Task<Webhook> ModifyAsync(Action<WebhookOptions> action, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
actionAction<WebhookOptions>The modification to perform on the webhook.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.
Returns
Remarks
Requires the ManageWebhooks permission, and fires a WebhooksUpdate event.
Does not allow modifiying the ChannelId property.
ModifyMessageAsync(ulong, Action<MessageOptions>, ulong?, bool, RestRequestProperties?, CancellationToken)
Modifies a previously-sent webhook message.
public Task<RestMessage> ModifyMessageAsync(ulong messageId, Action<MessageOptions> action, ulong? threadId = null, bool withComponents = true, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)
Parameters
messageIdulongThe ID of the message to modify.
actionAction<MessageOptions>The modification to apply to the message.
threadIdulong?The ID of the thread the message is in.
withComponentsboolWhether to respect the modification's Components.
When enabled, allows application-owned webhooks to use all components, and non-owned webhooks to use non-interactive components.
propertiesRestRequestPropertiesOptional properties to customize the request, can be null.
cancellationTokenCancellationTokenA token that can be used to cancel the operation before it completes.