šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

discord-webhook-handler

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-webhook-handler

An easy-to-use package for sending, managing, and deleting Discord webhooks.

1.0.3
latest
Source
npm
Version published
Maintainers
1
Created
Source

discord-webhook-handler

An easy-to-use and lightweight package for sending, updating, and deleting Discord webhooks.

Quick Start

import { Webhook } from 'discord-webhook-handler';
const webhook = new Webhook('<url>');

try {
  // Send a message to the webhook
  await webhook.send({
    content: 'Hello, world!',
  });

  // Update the webhook's name and avatar
  await webhook.update({
    name: 'Hookcord',
    avatar: 'https://example.com/image.png',
  });

  // Fetch information about the webhook
  const webhookInfo = await webhook.fetch();
  console.log(webhookInfo.name); // Outputs: "Hookcord"

  // Delete the webhook
  await webhook.delete();
} catch (error) {
  console.error(error);
}

Methods

MethodDescriptionReturns
sendSend's provided content to webhook<Boolean>
updateUpdate's webhooks info<Boolean>
fetchRetrieves information about webhook<WebhookInfo>
deleteDelete's webhook<Boolean>
new Webhook("<url>", {
    username: "Example Webhook",
    avatar_url: "example.com/image.png"
})

webhook.send({
  content: "Example Content",
  tts: false,
  embeds: [
    {
      title: "Example Embed",
      description: "This is an example of an embed.",
      url: "https://discordapp.com",
      color: 15258703,
      timestamp: "2022-05-05T12:00:00.000Z",
      footer: {
        text: "Example Footer",
        icon_url: "https://example.com/footer.png"
      },
      thumbnail: {
        url: "https://example.com/thumbnail.png"
      },
      image: {
        url: "https://example.com/image.png"
      },
      author: {
        name: "Example Author",
        url: "https://example.com/author",
        icon_url: "https://example.com/author.png"
      },
      fields: [
        {
          name: "Example Field 1",
          value: "This is an example field.",
          inline: true
        }
      ]
    }
  ]
});

webhook.update({
  name: 'Webhook Example',
  avatar: 'https://example.com/image.jpg',
});

webhook.fetch()

webhook.delete()

Keywords

discord

FAQs

Package last updated on 06 May 2023

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