Class WebhookMethods

Methods for handling webhook interactions

Hierarchy

  • WebhookMethods

Constructors

  • Create a new Method Handler

    Usually SnowTransfer creates a method handler for you, this is here for completion

    You can access the methods listed via client.webhook.method, where client is an initialized SnowTransfer instance

    Parameters

    • requestHandler: RequestHandler

      request handler that calls the rest api

    • disableEveryone: boolean

      Disable [at]everyone/[at]here on outgoing messages

    Returns WebhookMethods

Methods

  • Create a new Webhook

    Returns

    Webhook Object

    Permissions needed Condition
    MANAGE_WEBHOOKS always

    Example

    // Create a new Webhook with the name "Webby Webhook"
    const client = new SnowTransfer("TOKEN")
    const webhookData = {
    name: "Webby Webhook"
    }
    const webhook = await client.webhook.createWebhook("channel Id", webhookData)

    Parameters

    • channelId: string

      Id of the channel

    • data: {
          avatar?: null | string;
          name: string;
          reason?: string;
      }

      Object with webhook properties

      • Optional avatar?: null | string
      • name: string
      • Optional reason?: string

    Returns Promise<Webhook>

  • Delete a Webhook

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_WEBHOOKS without token

    Example

    // Delete a webhook via Id providing a webhook token
    const client = new SnowTransfer(); // No token needed if webhook token is provided
    client.webhook.deleteWebhook("webhook Id", "webhook token")

    Parameters

    • webhookId: string

      Id of the webhook

    • Optional token: string

      Webhook token

    Returns Promise<void>

  • Delete a message sent by a Webhook

    Returns

    Resolves the Promise on successful execution

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • messageId: string

      Id of the message

    • Optional threadId: string

      Id of the thread the message was sent in

    Returns Promise<void>

  • Edit a message sent by a Webhook

    Returns

    discord message object

    Example

    const client = new SnowTransfer()
    const message = await client.webhook.editWebhookMessage("webhook Id", "webhook token", "message Id", { content: "New content" })

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • messageId: string

      Id of the message

    • data: WebhookEditMessageData

      Data to send

    Returns Promise<Message>

  • Send a message via Webhook

    Returns

    Resolves the Promise on successful execution unless wait is set to true, which returns a message object

    Example

    // Send a message saying "Hi from my webhook" with a previously created webhook
    const client = new SnowTransfer()
    client.webhook.executeWebhook("webhook Id", "webhook token", {content: "Hi from my webhook"})

    Parameters

    • webhookId: string

      Id of the webhook

    • token: string

      webhook token

    • data: WebhookCreateMessageData

      Webhook data to send

    • Optional options: {
          disableEveryone?: boolean;
          thread_id?: string;
          wait?: false;
      }

      Options for executing the webhook

      • Optional disableEveryone?: boolean
      • Optional thread_id?: string
      • Optional wait?: false

    Returns Promise<void>

  • Parameters

    • webhookId: string
    • token: string
    • data: WebhookCreateMessageData
    • options: {
          disableEveryone?: boolean;
          thread_id?: string;
          wait: true;
      }
      • Optional disableEveryone?: boolean
      • Optional thread_id?: string
      • wait: true

    Returns Promise<Message>

  • Executes a github style Webhook

    Returns

    Resolves the Promise on successful execution

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • data: GitHubWebhookData
    • Optional options: {
          thread_id?: string;
          wait?: boolean;
      }

      Options for executing the webhook

      • Optional thread_id?: string
      • Optional wait?: boolean

    Returns Promise<void>

  • Execute a slack style Webhook

    Returns

    Resolves the Promise on successful execution

    Example

    const client = new SnowTransfer() // No token needed
    client.webhook.executeSlackWebhook("webhook Id", "webhook token", slackdata)

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • data: any
    • options: undefined | {
          disableEveryone?: boolean;
          thread_id?: string;
          wait?: boolean;
      } = ...

      Options for executing the webhook

    Returns Promise<void>

  • Get all webhooks within a channel

    Returns

    Array of Webhook Objects

    Permissions needed Condition
    MANAGE_WEBHOOKS always

    Example

    // Get all webhooks within a channel
    const client = new SnowTransfer("TOKEN")
    const webhooks = await client.webhook.getChannelWebhooks("channel Id")

    Parameters

    • channelId: string

      Id of the channel

    Returns Promise<Webhook[]>

  • Get all webhooks within a guild

    Returns

    Array of Webhook Objects

    Permissions needed Condition
    MANAGE_WEBHOOKS always

    Example

    // Get all webhooks within a guild
    const client = new SnowTransfer("TOKEN")
    const webhooks = await client.webhook.getGuildWebhooks("guild Id")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<Webhook[]>

  • Get a single Webhook via Id

    Returns

    Webhook Object

    Permissions needed Condition
    MANAGE_WEBHOOKS without token

    Example

    // Get a webhook via Id providing a webhook token
    const client = new SnowTransfer() // No token needed if webhook token is provided
    const webhook = await client.webhook.getWebhook("webhook Id", "webhook token")

    Parameters

    • webhookId: string

      Id of the webhook

    • Optional token: string

      Webhook token

    Returns Promise<Webhook>

  • Get a single message from a specific Webhook via Id

    Returns

    discord message object

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • messageId: string

      Id of the message

    • Optional threadId: string

      Id of the thread the message was sent in

    Returns Promise<Message>

  • Update a webhook

    Returns

    Updated Webhook Object

    Permissions needed Condition
    MANAGE_WEBHOOKS without token

    Example

    // Rename a webhook to "Captain Hook" with a webhook token
    const client = new SnowTransfer(); // No token needed if webhook token is provided
    const webhookData = {
    name: "Captain Hook"
    }
    const webhook = await client.webhook.updateWebhook("webhook Id", "webhook token", webhookData)

    Parameters

    • webhookId: string

      Id of the webhook

    • token: string

      Webhook token

    • data: {
          avatar?: null | string;
          channel_id?: string;
          name?: string;
          reason?: string;
      }

      Updated Webhook properties

      • Optional avatar?: null | string
      • Optional channel_id?: string
      • Optional name?: string
      • Optional reason?: string

    Returns Promise<Webhook>

  • Parameters

    • webhookId: string
    • token: undefined
    • data: {
          avatar?: null | string;
          name?: string;
          reason?: string;
      }
      • Optional avatar?: null | string
      • Optional name?: string
      • Optional reason?: string

    Returns Promise<Webhook>

Properties

disableEveryone: boolean
requestHandler: RequestHandler

Generated using TypeDoc