import type { ReturnCache } from '../cache'; import { type AnonymousGuildStructure, type GuildStructure, type UserStructure, type WebhookMessageStructure, type WebhookStructure } from '../client/transformers'; import type { UsingClient } from '../commands'; import type { ImageOptions, MessageWebhookCreateBodyRequest, MessageWebhookPayload, MessageWebhookUpdateBodyRequest, MethodContext, ObjectToLower, WebhookShorterMessageDeleteParams, WebhookShorterMessageFetchParams } from '../common'; /** * Represents a Discord webhook. */ import type { APIWebhook, RESTPatchAPIWebhookJSONBody, RESTPatchAPIWebhookWithTokenJSONBody, RESTPatchAPIWebhookWithTokenMessageQuery, RESTPostAPIWebhookWithTokenQuery } from '../types'; import type { AllChannels } from './channels'; import { DiscordBase } from './extra/DiscordBase'; export interface Webhook extends DiscordBase, ObjectToLower> { } /** * Represents a Discord webhook. */ export declare class Webhook extends DiscordBase { /** The user associated with the webhook, if applicable. */ user?: UserStructure; /** The source guild of the webhook, if applicable. */ sourceGuild?: Partial; /** Methods related to interacting with messages through the webhook. */ messages: ReturnType; /** * Constructs a new Webhook instance. * @param client The Discord client instance. * @param data The data representing the webhook. */ constructor(client: UsingClient, data: APIWebhook); /** * Fetches the guild associated with the webhook. * @param 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. */ guild(mode?: 'rest' | 'flow'): Promise | undefined>; guild(mode: 'cache'): ReturnCache | undefined>; /** * Fetches the channel associated with the webhook. * @param 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. */ channel(mode?: 'rest' | 'flow'): Promise; channel(mode: 'cache'): ReturnCache; /** * Retrieves the avatar URL of the webhook. * @param options The image options for the avatar. * @returns The avatar URL of the webhook, or null if no avatar is set. */ avatarURL(options?: ImageOptions): string | null; /** * Fetches the webhook data from the Discord API. * @returns A promise that resolves to the fetched webhook data. */ fetch(): Promise; /** * Edits the webhook. * @param body The new webhook data. * @param reason The reason for editing the webhook. * @returns A promise that resolves when the webhook is successfully edited. */ edit(body: RESTPatchAPIWebhookJSONBody | RESTPatchAPIWebhookWithTokenJSONBody, reason?: string): Promise; /** * Deletes the webhook. * @param reason The reason for deleting the webhook. * @returns A promise that resolves when the webhook is successfully deleted. */ delete(reason?: string): Promise; /** * Static methods related to interacting with messages through webhooks. */ static messages({ client, webhookId, webhookToken }: MethodContext<{ webhookId: string; webhookToken: string; }>): { /** Writes a message through the webhook. */ write: { (payload: MessageWebhookMethodWriteWaitParams): Promise; (payload: MessageWebhookMethodWriteParams): Promise; }; /** Edits a message sent through the webhook. */ edit: (payload: MessageWebhookMethodEditParams) => Promise; /** Deletes a message sent through the webhook. */ delete: (payload: MessageWebhookMethodDeleteParams) => Promise; fetch: (payload: MessageWebhookMethodFetchParams) => Promise; }; /** * Static methods related to managing webhooks. */ static methods({ client, webhookId, webhookToken }: MethodContext<{ webhookId: string; webhookToken?: string; }>): { /** Deletes the webhook. */ delete: (reason?: string) => Promise; /** Edits the webhook. */ edit: (body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, reason?: string) => Promise; /** Fetches the webhook data from the Discord API. */ fetch: () => Promise; }; } /** Type definition for parameters of editing a message through a webhook. */ export type MessageWebhookMethodEditParams = MessageWebhookPayload; /** Type definition for parameters of writing a message through a webhook. */ export type MessageWebhookMethodWriteParams = MessageWebhookPayload; export type MessageWebhookMethodWriteWaitParams = MessageWebhookPayload; export type MessageWebhookMethodDeleteParams = Omit; export type MessageWebhookMethodFetchParams = Omit;