A user-friendly, sleek and fast client used to create and send Discord Webhooks.
- Object-oriented
- Complete coverage of the Discord Webhook API
- Lightweight but powerful
API Documentation available at maxrumsey.xyz/hookcord/
$ npm i hookcord
var hookcord = require('hookcord');
var Hook = new hookcord.Hook()
.login('ID', 'SECRET')
.setPayload(payload)
.fire()
.then(function(response) {})
.catch(function(e) {})
Or:
var hookcord = require('hookcord');
var Hook = new hookcord.Hook()
.setLink('https://abc.com/webhook')
.setPayload(payload)
.fire()
.then(function(response) {})
.catch(function(e) {})
var hookcord = require('hookcord');
var Hook = new hookcord.Hook()
.login('ID', 'SECRET')
.setPayload({
'content': 'This displays like a normal message.'
})
.fire()
.then(function(response) {})
.catch(function(e) {})
More information is available at the documentation.
var hookcord = require('hookcord');
var Hook = new hookcord.Hook()
.login('ID', 'SECRET')
.setPayload({'embeds': [{ // .setPayload(hookcord.DiscordJS(embed))
'title': 'Hookcord',
'description': '',
'fields': [{
'name': 'Version',
'value': '1.0.0',
'inline': true
}],
'timestamp': new Date();
}]})
.fire()
.then(function(response) {})
.catch(function(e) {})
Embed documentation is available at Discord's Documentation. More information is available at the Hookcord documentation.
By default, Hookcord will throw an error if it encounters a ratelimit. You can override this by setting a handler function like this:
var hookcord = require('hookcord');
var Hook = new hookcord.Hook()
.login('ID', 'SECRET')
.setOptions({
handler: function(err) {
console.log('Ratelimit Request Limit: ' + err.limit);
console.log('Remaining Requests: ' + err.remaining);
console.log('Time until Reset: ' + err.reset)
}
})
.setPayload({ contents: ':)' })
.fire()
It provides the remaining requests allowed (0), the total requests permitted (usually 5) and the time until the Ratelimit resets.
More information is available at the Hookcord documentation.
Hookcord has the ability to parse embeds created via Discord.JS's RichEmbed. These parsed embeds can be sent via Hookcord as a Webhook.
var hookcord = require('hookcord');
var Hook = new hookcord.Hook()
.login('ID', 'SECRET')
.setPayload(hookcord.DiscordJS(embed))
.fire()
.then(function(response) {})
.catch(function(e) {})
If you attempt to parse a file, the file will be removed and the incident will be logged to console.
If you wish to contribute, feel free to open a pull request on the GitHub Repository! Also, make sure to join our Discord Server!