Webhooks.js is a new, lightweight, and fast Node.js wrapper for the Discord Webhooks API.
- Object Oriented
- Up-to-Date
Node.js 12 or newer is required.
npm install webhooks.js --save
You can send a raw Webhook params object Read More
const hooks = require('webhooks.js')
const hook = new hooks.Webhook({ id: "your-webhook-id", token: "your-webhook-token" })
hook.send({
username: "Webhook",
content: "Hello!",
embeds: [{
title: "hello!"
}]
})
.then(json => {
console.log(json)
})
.catch(err => {
console.error(err)
})
or you can send a string
const hooks = require('webhooks.js')
const hook = new hooks.Webhook({ id: "your-webhook-id", token: "your-webhook-token" })
hook.send("hello world!")
.then(json => {
console.log(json)
})
.catch(err => {
console.error(err)
})
or you can send a RichEmbed (different from Discord.js MessageEmbeds)
const hooks = require('webhooks.js')
const hook = new hooks.Webhook({ id: "your-webhook-id", token: "your-webhook-token" })
const embed = new hooks.RichEmbed()
.setTitle(`Embed test`)
.setTimestamp()
.setDescription("Test..?")
hook.send(embed)
.then(json => {
console.log(json)
})
.catch(err => {
console.error(err)
})
You can get help in the Webhooks.js Discord Server in the #support channel.