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
request handler that calls the rest api
Disable [at]everyone/[at]here on outgoing messages
Create a new Webhook
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | always |
// 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)
Id of the channel
Object with webhook properties
Optional
avatar?: null | stringOptional
reason?: stringDelete a Webhook
Resolves the Promise on successful execution
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | without token |
// 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")
Id of the webhook
Optional
token: stringWebhook token
Delete a message sent by a Webhook
Resolves the Promise on successful execution
Id of the Webhook
Webhook token
Id of the message
Optional
threadId: stringId of the thread the message was sent in
Edit a message sent by a Webhook
discord message object
const client = new SnowTransfer()
const message = await client.webhook.editWebhookMessage("webhook Id", "webhook token", "message Id", { content: "New content" })
Id of the Webhook
Webhook token
Id of the message
Data to send
Send a message via Webhook
Resolves the Promise on successful execution unless wait is set to true, which returns a message object
// 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"})
Id of the webhook
webhook token
Webhook data to send
Optional
options: { Options for executing the webhook
Optional
disableOptional
thread_Optional
wait?: falseOptional
disableOptional
thread_Executes a github style Webhook
Resolves the Promise on successful execution
Id of the Webhook
Webhook token
Check GitHub's documentation
Optional
options: { Options for executing the webhook
Optional
thread_Optional
wait?: booleanExecute a slack style Webhook
Resolves the Promise on successful execution
const client = new SnowTransfer() // No token needed
client.webhook.executeSlackWebhook("webhook Id", "webhook token", slackdata)
Id of the Webhook
Webhook token
Check Slack's documentation
Options for executing the webhook
Get all webhooks within a channel
Array of Webhook Objects
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | always |
// Get all webhooks within a channel
const client = new SnowTransfer("TOKEN")
const webhooks = await client.webhook.getChannelWebhooks("channel Id")
Id of the channel
Get all webhooks within a guild
Array of Webhook Objects
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | always |
// Get all webhooks within a guild
const client = new SnowTransfer("TOKEN")
const webhooks = await client.webhook.getGuildWebhooks("guild Id")
Id of the guild
Get a single Webhook via Id
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | without token |
// 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")
Id of the webhook
Optional
token: stringWebhook token
Id of the Webhook
Webhook token
Id of the message
Optional
threadId: stringId of the thread the message was sent in
Update a webhook
Updated Webhook Object
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | without token |
// 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)
Id of the webhook
Webhook token
Updated Webhook properties
Optional
avatar?: null | stringOptional
channel_Optional
name?: stringOptional
reason?: stringOptional
avatar?: null | stringOptional
name?: stringOptional
reason?: stringGenerated using TypeDoc
Methods for handling webhook interactions