npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-hook-api

v1.0.3

Published

A Node.js Module to post to Discord Webhooks

Downloads

7

Readme

Discord Hook

A Node.js Module to post to Discord Webhooks.

Examples

Check the example.js in the examples folder

Installation

Simply run npm i discord-hook-api or yarn add discord-hook-api

Documentation

Put this somewhere on the top of your document

const { Hook, Embed } = require('discord-hook-api')

Hook Methods

To get started, you need to give up the webhook URL and append the methods using .method(argument) on the next lines.

webhook(url)

Pass the url for the webhook, there are two ways to pass it. Argument(s): string

new Hook()
  .webhook(webhook_url_here)
// or
new Hook(webhook_url_here)

addEmbed(embed)

Simply add an embed to the post by using the addElement method, you pass an embed which you can make as well. More information later in this documenation. Argument(s): embed

new Hook()
  .addEmbed(embed)

setAvatar(avatar)

Overwrite the avatar set in the webhook settings on Discord, you need to pass an URL to it which directly leads to a file. You can use something like file.coffee for it. Argument(s): string

new Hook()
  .setAvatar(url)

setContent(content)

This is the message you want to display, you can leave it blank if you are gonna send an embed. Argument(s): string

new Hook()
  .setAvatar(content)

setUsername(username)

Overwrite the username set in the webhook settings on Discord, you need to pass a string. Argument(s): string

new Hook()
  .setUsername(username)

setTts()

Want to make the webhook speak to all it's users, you can do it. Argument(s): none

new Hook()
  .setTts(boolean)

send()

Done making the message? Run this method and it will be delivered to Discord. Argument(s): none

new Hook()
  .send()

Embed Methods

Want to send a fancy message? The Embed class got you covered. Start with the following and append the methods using .method(argument) on the next lines.

const embed = new Embed()

setTitle(title)

Set the title of the embed Argument(s): string

const embed = new Embed()
  .setTitle(title)

setDescription(description)

Set the description of the embed Argument(s): string

const embed = new Embed()
  .setDescription(description)

setUrl(url)

Set the url of the embed Argument(s): string

const embed = new Embed()
  .setUrl(url)

setTimestamp(timestamp)

Set the timestamp for the footer of the timestamp, you don't need to pass an argument and it will pick the current time. Argument(s): string

const embed = new Embed()
  .setTimestamp(timestamp)

setColor(setColor)

Set the color of the embed Argument(s): integer

const embed = new Embed()
  .setColor(setColor)

setFooter(text, icon)

Set the footer of the embed, the icon is optional if you are using this method. Argument(s): string, string

const embed = new Embed()
  .setFooter(text, icon)

setImage(url)

Set the image of the embed Argument(s): string

const embed = new Embed()
  .setImage(url)

setThumbnail(url)

Set the thumbnail of the embed Argument(s): string

const embed = new Embed()
  .setThumbnail(url)

setVideo(url)

Set the video of the embed Argument(s): string

const embed = new Embed()
  .setVideo(url)

setAuthor(name, icon, url)

Set the author of the embed, icon and url are optional. Argument(s): string, string, string

const embed = new Embed()
  .setAuthor(name, icon, url)

addField(name, value, inline)

Add a field to the embed, max is 25 fields. Argument(s): string

const embed = new Embed()
  .addField(name, value, inline)

License

Released under the MIT License