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
default: typeof <internal>.WebhookMethods

Methods

  • createWebhook(channelId: string, data: { avatar?: null | string; name: string; reason?: string }): Promise<<internal>.Webhook>
  • Create a new Webhook

    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<<internal>.Webhook>

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

    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>

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_WEBHOOKS without token
  • deleteWebhookMessage(webhookId: string, token: string, messageId: string, threadId?: 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

    • Optional threadId: string

      Id of the thread the message was sent in

    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() 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 }

      Options for executing the webhook

      • 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 executing the webhook

      • 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

    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
    • Optional options: { disableEveryone?: boolean; thread_id?: string; wait?: boolean }

      Options for executing the webhook

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

    Returns Promise<void>

    Resolves the Promise on successful execution

  • Get all webhooks within a channel

    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<<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") const webhooks = await client.webhook.getGuildWebhooks("guild Id")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<<internal>.Webhook[]>

    Array of Webhook Objects

    Permissions needed Condition
    MANAGE_WEBHOOKS always
  • Get a single Webhook via Id

    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<<internal>.Webhook>

    (https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure)

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

    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<<internal>.Webhook>

    Updated Webhook Object

    Permissions needed Condition
    MANAGE_WEBHOOKS without token
  • 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<<internal>.Webhook>

Generated using TypeDoc