Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webhook-builder

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webhook-builder

Build a webhook with this package

  • 1.1.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Webhook Builder

version npm


Sections

  • Installation
  • Examples
  • API
  • More Features

Installation

With NPM

$ npm install webhook-builder

With yarn

$ yarn add webhook-builder

Examples

Basic Use

/* ================================================================================= */
//                                   Example                                         //
/* ================================================================================= */

// Make sure you require the file.
// e.g: const { Webhook, MessageBuilder } = require("webhook-builder");

const webhook = new Webhook("your webhook url here");

// If you want to set a username and an icon/avatar for the webhook. Do this:
webhook.setWebhook({
  username: "Your webhook username",
  avatar_url: "Your avatar/icon URL",
});

// MessageBuilder (Object)
const mb = new MessageBuilder("Your content here", {
  title: "Hello World!",
  description: "This is a description",
  color: "#fff",
});

// MessageBuilder (methods)
const mb = new MessageBuilder("Your content here")
  .setTitle("Hello World!")
  .setDescription("This is a description")
  .setColor("#fff");

// Sending the webhook (Without promise prototypes)
webhook.send(mb);

// Sending the webhook (with promise prototypes)
webhook
  .send(mb)
  .then(() => {
    console.log("The webhook has been sended successfully!");
  })
  .catch((err) => {
    // Throws an error, if there is an error sending the webhook
    throw new Error(err);
  });

API


Webhook (Class)

Constructor:
  • webhookURL: "String" | "URL"
Methods:
  • setWebhook

    • data: "Object"
      • username: "String"
      • avatar_url: "String"
  • send

    • content (optional): "String"
    • embed (optional): "MessageBuilder"

    *(Content and embed parameters mustn't be null or empty)*
    *EG:*
    ```js // No. It's not gonna work webhook.send(null, null);

    // But this is valid webhook.send(null, mb);

    // And this webhook.send("Hello World!");


Message Builder (Class)

Constructor:
  • Embed Object: "Object"
Methods:
  • setTitle

    • title: "String"
  • setURL

    • titleURL: "String" | "URL"
  • setDescription

    • description: "String"
  • setColor

    • color: "String" | "Number"
  • setAuthor

    • authorOpts: "Object"
      • name: "String"
      • icon_url (optional): "String" | "URL"
      • url (optional): "String" | "URL"
  • setThumbnail

    • url: "String" | "URL"
  • setField

    • footerOpts: "Object[]"
      • name: "String"
      • value: "String"
      • inline (optional): "Boolean"
  • setFooter - footerText: "String" - footerIcon (optional): "String" | "URL"


More features will come soon!


Keywords

FAQs

Package last updated on 19 Nov 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc