Class Webhook
Represents a webhook, a low-effort way to post messages to channels in Discord. They do not require a bot user or authentication to use.
public class Webhook : ClientEntity, IEntity, ISpanFormattable, IFormattable, IEquatable<Entity>, IJsonModel<JsonWebhook>
- Inheritance
-
Webhook
- Implements
- Derived
- Inherited Members
Constructors
Webhook(JsonWebhook, RestClient)
public Webhook(JsonWebhook jsonModel, RestClient client)
Parameters
jsonModelJsonWebhookclientRestClient
Properties
ApplicationId
The ID of the bot or OAuth2 application that created this webhook.
public ulong? ApplicationId { get; }
Property Value
AvatarHash
The default user avatar hash of the webhook.
public string? AvatarHash { get; }
Property Value
Channel
The channel that this webhook is following.
public Channel? Channel { get; }
Property Value
Remarks
This property is null if Type is not ChannelFollower, or if the Creator has lost access to the guild where the Channel resides.
ChannelId
The channel ID this webhook targets. Can be null.
public ulong? ChannelId { get; }
Property Value
Creator
The User this webhook was created by.
public User? Creator { get; }
Property Value
Remarks
This property is null if the webhook was retrieved using its token.
Guild
The guild of the channel followed by this webhook.
public RestGuild? Guild { get; }
Property Value
Remarks
This property is null if Type is not ChannelFollower, or if the Creator has lost access to the guild where the Channel resides.
GuildId
The guild ID this webhook targets. Can be null.
public ulong? GuildId { get; }
Property Value
Id
The ID of the webhook.
public override ulong Id { get; }
Property Value
Name
The default name of the webhook.
public string? Name { get; }
Property Value
Remarks
A webhook name is valid if:
- The string length is between 1 and 80 characters.
-
It does not contain the substrings
clydeordiscord(case-insensitive). - It follows Discord's nickname guidelines, found here.
Type
The type of the webhook.
public WebhookType Type { get; }
Property Value
Url
The URL used for executing the webhook.
public string? Url { get; }
Property Value
Methods
CreateFromJson(JsonWebhook, RestClient)
public static Webhook CreateFromJson(JsonWebhook jsonModel, RestClient client)
Parameters
jsonModelJsonWebhookclientRestClient
Returns
DeleteAsync(RestRequestProperties?, CancellationToken)
Deletes a webhook permanently.
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
Fires a WebhooksUpdate event.
GetAsync(RestRequestProperties?, CancellationToken)
Retrieves a Webhook object for the given ID.
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
ModifyAsync(Action<WebhookOptions>, RestRequestProperties?, CancellationToken)
Modifies a webhook, 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.