Table of Contents
About
Webhooks.js is a new, lightweight, and fast Node.js wrapper for the Discord Webhooks API.
- Object Oriented
- Up-to-Date
Installation
Node.js 12 or newer is required.
npm install webhooks.js --save
Examples
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)
})
Links
Help
You can get help in the Webhooks.js Discord Server in the #support channel.
Updates
v0.0.1
- Published initial working code without README
v0.0.2
- Published updated code with README
v0.0.3
- Added typings and cleaned up some code.