Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebhookMethods

Methods for handling webhook interactions

Hierarchy

  • WebhookMethods

Index

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: <internal>.RequestHandler

      request handler that calls the rest api

    • disableEveryone: boolean

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

    Returns <internal>.WebhookMethods

Properties

disableEveryone: boolean
requestHandler: <internal>.RequestHandler

Methods

  • Create a new Webhook

    example

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

    Parameters

    • channelId: string

      Id of the channel

    • data: { avatar?: string; name: string }

      Object with webhook properties

      • Optional avatar?: string
      • name: string

    Returns Promise<<internal>.Webhook>

  • deleteWebhook(webhookId: string, token?: string): Promise<void>
  • Delete a Webhook

    Parameters

    • webhookId: string

      Id of the webhook

    • Optional token: string

      Webhook token

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_WEBHOOKS without token
  • deleteWebhookMessage(webhookId: string, token: string, messageId: string): Promise<void>
  • Delete a message sent by a Webhook

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • messageId: string

      Id of the message

    Returns Promise<void>

    Resolves the Promise on successful execution

  • Send a message via Webhook

    example

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

    Parameters

    • webhookId: string

      Id of the webhook

    • token: string

      webhook token

    • data: <internal>.WebhookCreateMessageData

      Webhook data to send

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

    Returns Promise<void>

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

  • Parameters

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

    Returns Promise<<internal>.Message>

  • Executes a github style Webhook

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

    • data: <internal>.GitHubWebhookData
    • Optional options: { thread_id?: string; wait?: boolean }

      Options for disabling everyone/here pings or setting the wait query string

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

    Returns Promise<void>

    Resolves the Promise on successful execution

  • executeWebhookSlack(webhookId: string, token: string, data: any, options?: { disableEveryone?: boolean; thread_id?: string; wait?: boolean }): Promise<void>
  • Execute a slack style Webhook

    Parameters

    • webhookId: string

      Id of the Webhook

    • token: string

      Webhook token

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

      Options for disabling everyone/here pings or setting the wait query string

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

    Returns Promise<void>

    Resolves the Promise on successful execution

  • Get webhooks created within a channel

    example

    // Get all webhooks within a channel const client = new SnowTransfer('TOKEN'); client.webhook.getWebhooksChannel('channel Id').then(console.log);

    Parameters

    • channelId: string

      Id of the channel

    Returns Promise<<internal>.Webhook[]>

    Array of Webhook Objects

    Permissions needed Condition
    MANAGE_WEBHOOKS always
  • Get all webhooks within a guild

    example

    // Get all webhooks within a guild const client = new SnowTransfer('TOKEN'); client.webhook.getWebhooksGuild('guild Id').then(console.log);

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<<internal>.Webhook[]>

    Array of Webhook Objects

    Permissions needed Condition
    MANAGE_WEBHOOKS always
  • updateWebhook(webhookId: string, token: undefined | string, data: { avatar?: string; channel_id?: string; name?: string }): Promise<<internal>.Webhook>
  • Update a webhook

    example

    // Rename a webhook to "Captain Hook" const client = new SnowTransfer('TOKEN'); const webhookData = { name: 'Captain Hook' } client.webhook.updateWebhook('webhook Id', 'webhook token', webhookData);

    Parameters

    • webhookId: string

      Id of the webhook

    • token: undefined | string

      Webhook token

    • data: { avatar?: string; channel_id?: string; name?: string }

      Updated Webhook properties

      • Optional avatar?: string
      • Optional channel_id?: string
      • Optional name?: string

    Returns Promise<<internal>.Webhook>

    Updated Webhook Object

    Permissions needed Condition
    MANAGE_WEBHOOKS without token

Generated using TypeDoc