Socket
Book a DemoInstallSign in
Socket

hookcord

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hookcord

A user-friendly, sleek and fast client used to create and send Discord Webhooks.

2.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Discord Dependencies Coverage Status Build Status npm npm npm Greenkeeper badge install size

npm

Hookcord

A user-friendly, sleek and fast client used to create and send Discord Webhooks.

Features

  • Object-oriented
  • Complete coverage of the Discord Webhook API
  • Lightweight but powerful

API Documentation available at maxrumsey.xyz/hookcord/

Usage

Installation

$ npm i hookcord

Initialisation

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

Messages

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.

Embeds

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.

Ratelimits

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.

Parsing Discord.JS Embeds

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.

Contributing

If you wish to contribute, feel free to open a pull request on the GitHub Repository! Also, make sure to join our Discord Server!

Keywords

Discord

FAQs

Package last updated on 29 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.