Webhook
Represents a Discord webhook.
Signature
export declare class Webhook extends DiscordBaseProperties
16Methods
9Properties
user?: UserStructure;The user associated with the webhook, if applicable.
sourceGuild?: Partial<AnonymousGuildStructure>;The source guild of the webhook, if applicable.
messages: ReturnType<typeof Webhook.messages>;Methods related to interacting with messages through the webhook.
id: string;createdTimestampGetterget createdTimestamp(): number;Create a timestamp for the current object.
createdAtGetterget createdAt(): Date;createdAt gets the creation Date instace of the current object.
readonly client: UsingClient;type: WebhookType;url?: string | undefined;guildId?: string | undefined;avatar: string | null;token?: string | undefined;name: string | null;applicationId: string | null;channelId: string;sourceChannel?: { id: string; type: ChannelType; name?: string | null | undefined; } | undefined;Methods
constructorConstructorconstructor(client: UsingClient, data: APIWebhook);guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;Fetches the guild associated with the webhook.
force- Whether to force fetching the guild even if it's already cached.
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.
force- Whether to force fetching the channel even if it's already cached.
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.
options- The image options for the avatar.
The avatar URL of the webhook, or null if no avatar is set.
fetch(): Promise<WebhookStructure>;Fetches the webhook data from the Discord API.
A promise that resolves to the fetched webhook data.
edit(body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, reason?: string): Promise<WebhookStructure>;Edits the webhook.
body- The new webhook data.
reason- The reason for editing the webhook.
A promise that resolves when the webhook is successfully edited.
delete(reason?: string): Promise<undefined>;Deletes the webhook.
reason- The reason for deleting the webhook.
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.
static methods({ client, webhookId, webhookToken }: MethodContext<{ webhookId: string; webhookToken?: string;}>): { delete: (reason?: string) => Promise<undefined>; edit: (body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, reason?: string) => Promise<Webhook>; fetch: () => Promise<Webhook>;};Static methods related to managing webhooks.