stoatbot.js
    Preparing search index...

    Class WebhookManager

    Manages webhooks for the client. Provides methods for creating, managing, and sending messages through webhooks.

    Index

    Constructors

    Methods

    • Creates a new webhook in the specified channel.

      Parameters

      • channelId: string

        The ID of the channel where the webhook will be created

      • name: string

        The name of the webhook

      • Optionalavatar: string | Readable | File

        Optional avatar for the webhook. Can be a URL string, Readable stream, or File object

      Returns Promise<createWebhookResponse>

      Promise resolving to the created webhook response

      const webhook = await client.webhooks.create("channelId", "My Webhook", "https://example.com/avatar.png");
      
    • Deletes a webhook.

      Parameters

      • webhookId: string

        The ID of the webhook to delete

      • token: string

        The token of the webhook

      Returns Promise<void>

      Promise that resolves when the webhook is deleted

      await client.webhooks.delete("webhookId", "webhookToken");
      console.log("Webhook deleted successfully");
    • Retrieves partial information about a webhook using only its ID. This method provides limited webhook information without requiring a token.

      Parameters

      • webhookId: string

        The ID of the webhook to retrieve partial information for

      Returns Promise<createWebhookResponse>

      Promise resolving to the webhook response with partial information

      const partialWebhook = await client.webhooks.getPartial("webhookId");
      console.log(`Webhook name: ${partialWebhook.name}`);
    • Sends a message through a webhook.

      Parameters

      • webhookId: string

        The ID of the webhook to send the message through

      • token: string

        The token of the webhook

      • content: string | MessageOptions

        The message content. Can be a string or MessageOptions object with attachments and embeds

      Returns Promise<
          {
              _id: string;
              attachments?: | {
                  _id: string;
                  content_type: string;
                  deleted?: boolean
                  | null;
                  filename: string;
                  message_id?: string | null;
                  metadata:
                      | { type: "File" }
                      | { type: "Text" }
                      | { height: number; type: "Image"; width: number }
                      | { height: number; type: "Video"; width: number }
                      | { type: "Audio" };
                  object_id?: string | null;
                  reported?: boolean | null;
                  server_id?: string | null;
                  size: number;
                  tag: string;
                  user_id?: string | null;
              }[]
              | null;
              author: string;
              channel: string;
              content?: string
              | null;
              edited?: string | null;
              embeds?:
                  | (
                      | {
                          colour?: string
                          | null;
                          description?: string | null;
                          icon_url?: string | null;
                          image?:
                              | {
                                  height: number;
                                  size: "Large"
                                  | "Preview";
                                  url: string;
                                  width: number;
                              }
                              | null;
                          original_url?: string
                          | null;
                          site_name?: string | null;
                          special?:
                              | { type: "None" }
                              | { type: "GIF" }
                              | { id: string; timestamp?: string | null; type: "YouTube" }
                              | { content_type: "Channel"; id: string; type: "Lightspeed" }
                              | {
                                  content_type: "Video" | "Channel" | "Clip";
                                  id: string;
                                  type: "Twitch";
                              }
                              | { content_type: string; id: string; type: "Spotify" }
                              | { type: "Soundcloud" }
                              | { content_type: "Album" | "Track"; id: string; type: "Bandcamp" }
                              | { album_id: string; track_id?: string | null; type: "AppleMusic" }
                              | { id: string; type: "Streamable" }
                              | null;
                          title?: string | null;
                          type: "Website";
                          url?: string | null;
                          video?: { height: number; url: string; width: number } | null;
                      }
                      | {
                          height: number;
                          size: "Large"
                          | "Preview";
                          type: "Image";
                          url: string;
                          width: number;
                      }
                      | { height: number; type: "Video"; url: string; width: number }
                      | {
                          colour?: string | null;
                          description?: string | null;
                          icon_url?: string | null;
                          media?:
                              | {
                                  _id: string;
                                  content_type: string;
                                  deleted?: boolean
                                  | null;
                                  filename: string;
                                  message_id?: string | null;
                                  metadata:
                                      | { type: "File" }
                                      | { type: "Text" }
                                      | { height: number; type: "Image"; width: number }
                                      | { height: number; type: "Video"; width: number }
                                      | { type: "Audio" };
                                  object_id?: string | null;
                                  reported?: boolean | null;
                                  server_id?: string | null;
                                  size: number;
                                  tag: string;
                                  user_id?: string | null;
                              }
                              | null;
                          title?: string
                          | null;
                          type: "Text";
                          url?: string | null;
                      }
                      | { type: "None" }
                  )[]
                  | null;
              flags?: number;
              interactions?: {
                  reactions?: string[] | null;
                  restrict_reactions?: boolean;
              };
              masquerade?: | {
                  avatar?: string
                  | null;
                  colour?: string | null;
                  name?: string | null;
              }
              | null;
              member?: | {
                  _id: { server: string; user: string };
                  avatar?:
                      | {
                          _id: string;
                          content_type: string;
                          deleted?: boolean
                          | null;
                          filename: string;
                          message_id?: string | null;
                          metadata:
                              | { type: "File" }
                              | { type: "Text" }
                              | { height: number; type: "Image"; width: number }
                              | { height: number; type: "Video"; width: number }
                              | { type: "Audio" };
                          object_id?: string | null;
                          reported?: boolean | null;
                          server_id?: string | null;
                          size: number;
                          tag: string;
                          user_id?: string | null;
                      }
                      | null;
                  joined_at: string;
                  nickname?: string
                  | null;
                  roles?: string[];
                  timeout?: string | null;
              }
              | null;
              mentions?: string[]
              | null;
              nonce?: string | null;
              pinned?: boolean | null;
              reactions?: { [key: string]: string[] };
              replies?: string[] | null;
              role_mentions?: string[] | null;
              system?:
                  | { content: string; type: "text" }
                  | { by: string; id: string; type: "user_added" }
                  | { by: string; id: string; type: "user_remove" }
                  | { id: string; type: "user_joined" }
                  | { id: string; type: "user_left" }
                  | { id: string; type: "user_kicked" }
                  | { id: string; type: "user_banned" }
                  | { by: string; name: string; type: "channel_renamed" }
                  | { by: string; type: "channel_description_changed" }
                  | { by: string; type: "channel_icon_changed" }
                  | { from: string; to: string; type: "channel_ownership_changed" }
                  | { by: string; id: string; type: "message_pinned" }
                  | { by: string; id: string; type: "message_unpinned" }
                  | null;
              user?:
                  | {
                      _id: string;
                      avatar?: | {
                          _id: string;
                          content_type: string;
                          deleted?: boolean
                          | null;
                          filename: string;
                          message_id?: string | null;
                          metadata:
                              | { type: "File" }
                              | { type: "Text" }
                              | { height: number; type: "Image"; width: number }
                              | { height: number; type: "Video"; width: number }
                              | { type: "Audio" };
                          object_id?: string | null;
                          reported?: boolean | null;
                          server_id?: string | null;
                          size: number;
                          tag: string;
                          user_id?: string | null;
                      }
                      | null;
                      badges?: number;
                      bot?: { owner: string }
                      | null;
                      discriminator: string;
                      display_name?: string | null;
                      flags?: number;
                      online: boolean;
                      privileged?: boolean;
                      relations?: {
                          _id: string;
                          status:
                              | "User"
                              | "None"
                              | "Friend"
                              | "Outgoing"
                              | "Incoming"
                              | "Blocked"
                              | "BlockedOther";
                      }[];
                      relationship: | "User"
                      | "None"
                      | "Friend"
                      | "Outgoing"
                      | "Incoming"
                      | "Blocked"
                      | "BlockedOther";
                      status?: | {
                          presence?: "Online"
                          | "Idle"
                          | "Focus"
                          | "Busy"
                          | "Invisible"
                          | null;
                          text?: string | null;
                      }
                      | null;
                      username: string;
                  }
                  | null;
              webhook?: { avatar?: string | null; name: string }
              | null;
          },
      >

      Promise resolving to the sent message

      // Send a simple text message
      await client.webhooks.send("webhookId", "token", "Hello, world!");

      // Send a message with embeds and attachments
      await client.webhooks.send("webhookId", "token", {
      content: "Check out this image!",
      attachments: ["https://example.com/image.png"],
      embeds: [myEmbed]
      });