Check out the GitHub Releases page for the latest release notes.
npm install @glitch452/discord-webhook
import { MessageBuilder, Webhook } from '@glitch452/discord-webhook';
const hook = new Webhook('<YOUR_WEBHOOK_URL>');
hook.send('Hello there!');
import { MessageBuilder, Webhook } from '@glitch452/discord-webhook';
const message = new MessageBuilder('Hello there!')
.setUsername('Bot Name')
.setAvatarUrl('https://cdn.discordapp.com/embed/avatars/0.png');
const hook = new Webhook('<YOUR_WEBHOOK_URL>');
hook.send(message);
import { EmbedBuilder, MessageBuilder, Webhook } from '@glitch452/discord-webhook';
const hook = new Webhook('<YOUR_WEBHOOK_URL>');
const embed = new EmbedBuilder()
.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();
const message = new MessageBuilder().addEmbed(embed);
hook.send(message);
Keep in mind that the custom embed method setColor
takes in a decimal color or a hex color (pure black and white hex
colors will be inaccurate). You can convert hex colors to decimal using this website here:
https://convertingcolors.com
import { MessageBuilder, Webhook } from '@glitch452/discord-webhook';
const hook = new Webhook('<YOUR_WEBHOOK_URL>');
const message = new MessageBuilder().addFile('../yourFileName.png');
hook.send(message);
import { Webhook } from '@glitch452/discord-webhook';
const hook = new Webhook('<YOUR_WEBHOOK_URL>');
// Sends an information message
hook.info('**Information hook**', 'Information field title here', 'Information field value here');
// Sends a success message
hook.success('**Success hook**', 'Success field title here', 'Success field value here');
// Sends an warning message
hook.warning('**Warning hook**', 'Warning field title here', 'Warning field value here');
// Sends an error message
hook.error('**Error hook**', 'Error field title here', 'Error field value here');
import { Webhook } from '@glitch452/discord-webhook';
const hook = new Webhook({
url: '<YOUR_WEBHOOK_URL>',
// If throwErrors is set to false, no errors will be thrown if there is an error sending
throwErrors: false,
// retryOnLimit gives you the option to not attempt to send the message again if rate limited
retryOnLimit: false,
});
The scripts and documentation in this project are released under the MIT License as defined by the Open Source Initiative.