simplest-discord-webhook

1.2.0 • Public • Published

version npm

Important

This is my first package and I'm working on it, if you find any error or suggestion, send me a message to LyricalString#5222 ;)

Installation

npm install simplest-discord-webhook

Examples

Basic use

const Webhook = require('simplest-discord-webhook');
const hook = new Webhook("YOUR WEBHOOK URL");

hook.send('MESSAGE');

Custom embeds

const Webhook = require('simplest-discord-webhook');
const { MessageBuilder } = require('discord.js')
const hook = new Webhook("YOUR WEBHOOK URL");

const embed = new MessageBuilder()
.setTitle('My title here')
.setAuthor('Author here', 'https://cdn.discordapp.com/embed/avatars/0.png', 'https://www.google.com')
.setURL('https://www.google.com')
.addField('First field', 'this is inline', true)
.addField('Second field', 'this is not inline')
.setColor('#00b0f4')
.setThumbnail('https://cdn.discordapp.com/embed/avatars/0.png')
.setDescription('Oh look a description :)')
.setImage('https://cdn.discordapp.com/embed/avatars/0.png')
.setFooter('Hey its a footer', 'https://cdn.discordapp.com/embed/avatars/0.png')
.setTimestamp();

hook.send(embed);

This is an example with the full embed, but you can send less information on the embed :)```

Notes

simplest-discord-webhook is a promise based library, which means you can use .catch, .then, and await. For example:

const Webhook = require('simplest-discord-webhook');
const hook = new Webhook("YOUR WEBHOOK URL");

hook.send("Hello there!")
.then(() => console.log('Sent webhook successfully!'))
.catch(err => console.log(err.message));

or using async:

const Webhook = require('simplest-discord-webhook');
const hook = new Webhook("YOUR WEBHOOK URL");

(async () => {
    try {
        await hook.send('Hello there!');
        console.log('Successfully sent webhook!');
    }
    catch(e){
        console.log(e.message);
    };
})();

License

MIT

Package Sidebar

Install

npm i simplest-discord-webhook

Weekly Downloads

1

Version

1.2.0

License

ISC

Unpacked Size

9.67 kB

Total Files

5

Last publish

Collaborators

  • lyricalstring2