Webhook

Represents a Discord webhook.

Signature

export declare class Webhook extends DiscordBase

Properties

messages: ReturnType<typeof Webhook.messages>;

Methods related to interacting with messages through the webhook.

get createdTimestamp(): number;

Create a timestamp for the current object.

get createdAt(): Date;

createdAt gets the creation Date instace of the current object.

url?: string | undefined;
token?: string | undefined;
name: string | null;

Methods

guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;

Fetches the guild associated with the webhook.

Parameters
force
Whether to force fetching the guild even if it's already cached.
Returns

A promise that resolves to the guild associated with the webhook, or undefined if not applicable.

channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;channel(mode: 'cache'): ReturnCache<AllChannels | undefined>;

Fetches the channel associated with the webhook.

Parameters
force
Whether to force fetching the channel even if it's already cached.
Returns

A promise that resolves to the channel associated with the webhook, or undefined if not applicable.

avatarURL(options?: ImageOptions): string | null;

Retrieves the avatar URL of the webhook.

Parameters
options
The image options for the avatar.
Returns

The avatar URL of the webhook, or null if no avatar is set.

fetch(): Promise<WebhookStructure>;

Fetches the webhook data from the Discord API.

Returns

A promise that resolves to the fetched webhook data.

delete(reason?: string): Promise<undefined>;

Deletes the webhook.

Parameters
reason
The reason for deleting the webhook.
Returns

A promise that resolves when the webhook is successfully deleted.

static messages({ client, webhookId, webhookToken }: MethodContext<{    webhookId: string;    webhookToken: string;}>): {    write: {        (payload: MessageWebhookMethodWriteWaitParams): Promise<WebhookMessageStructure>;        (payload: MessageWebhookMethodWriteParams): Promise<WebhookMessageStructure | null>;    };    edit: (payload: MessageWebhookMethodEditParams) => Promise<WebhookMessageStructure>;    delete: (payload: MessageWebhookMethodDeleteParams) => Promise<undefined>;    fetch: (payload: MessageWebhookMethodFetchParams) => Promise<WebhookMessageStructure>;};

Static methods related to interacting with messages through webhooks.