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-easy-webhook

v1.1.7

Published

Discord-Easy-Webhooks is a Node.js module designed to manage and interact with webhooks. It provides convenient methods to send messages, embeds, files, and other types of interactions through webhooks.

Downloads

410

Readme

Discord-Easy-Webhooks

  • Discord-Easy-Webhooks is a Node.js module designed to manage and interact with webhooks. It provides convenient methods to send messages, embeds, files, and other types of interactions through webhooks.

Features

  • Send a message: Send a simple text message to a webhook.
  • Send an embed: Send a customized embed with a title, description, and color.
  • Send a message with a custom username: Send a message with a custom username.
  • Send an embed with fields: Send an embed with additional fields.
  • Send a file: Send a file attached to a message.
  • Send a TTS message: Send a text-to-speech (TTS) message.
  • Delete a message: Delete a message sent via the webhook.
  • Initialize the webhook: Set the webhook URL and check for updates.

Installation

  • Clone this repository to your machine or install it via npm if you publish it later.
  • Install the required dependencies.
npm i discord-easy-webhook

Usage

  • Import the module
const webhookManager = require('discord-easy-webhook');
const manager = new webhookManager();

Initialization

  • Before sending any messages, you need to initialize the webhook with its URL.
manager.init('https://your-webhook-url.com');

Sending a message

manager.sendMessage('Hello, world!')
  .then(response => {
    console.log('Message sent successfully!');
  })
  .catch(error => {
    console.error('Error sending message:', error);
  });

Sending an embed

manager.sendEmbed('Embed Title', 'Embed Description', 0xFF5733)
  .then(response => {
    console.log('Embed sent successfully!');
  })
  .catch(error => {
    console.error('Error sending embed:', error);
  });

Sending a message with a custom username

manager.sendMessageWithUsername('Hello, world!', 'Custom Username')
  .then(response => {
    console.log('Message sent with custom username!');
  })
  .catch(error => {
    console.error('Error sending message:', error);
  });

Sending an embed with fields

const fields = [
  { name: 'Field 1', value: 'Value 1' },
  { name: 'Field 2', value: 'Value 2' },
];

manager.sendEmbedWithFields('Embed Title', 'Embed Description', fields, 0x7289DA)
  .then(response => {
    console.log('Embed with fields sent successfully!');
  })
  .catch(error => {
    console.error('Error sending embed:', error);
  });

Sending a file

manager.sendFile('./path/to/your/file.txt', 'Here is a file attachment')
  .then(response => {
    console.log('File sent successfully!');
  })
  .catch(error => {
    console.error('Error sending file:', error);
  });

Sending a TTS message

manager.sendTTSMessage('This is a TTS message')
  .then(response => {
    console.log('TTS message sent successfully!');
  })
  .catch(error => {
    console.error('Error sending TTS message:', error);
  });

Deleting a message

manager.deleteMessage('message-id')
  .then(response => {
    console.log('Message deleted successfully!');
  })
  .catch(error => {
    console.error('Error deleting message:', error);
  });

API

init(url_webhook) Initializes the webhook URL.

  • url_webhook : The webhook URL to be used.

sendMessage(content) Sends a text message.

  • content : The content of the message to be sent.

  • sendEmbed(title, description, color) Sends a custom embed.

  • title : The title of the embed.

  • description : The description of the embed.

  • color : The color of the embed (default is 0x7289DA).

sendMessageWithUsername(content, username) Sends a message with a custom username.

  • content : The content of the message.

  • username : The custom username to display.

  • sendEmbedWithFields(title, description, fields, color) Sends an embed with additional fields.

  • title : The title of the embed.

  • description : The description of the embed.

  • fields : An array of fields with name and value pairs.

  • color : The color of the embed.

sendFile(filePath, message) Sends a file with a message.

  • filePath : The path to the file to send.
  • message : The message to accompany the file.

sendTTSMessage(content) Sends a text-to-speech (TTS) message.

  • content : The content of the message to be sent.

  • deleteMessage(messageId) Deletes a message sent via the webhook.

  • messageId: The ID of the message to delete.

Contributions

  • Contributions are welcome! Please submit a pull request or create an issue for suggestions or fixes.