node-discord-webhook
v1.0.1
Published
NodeJs & typescript Integration with discord webhook
Downloads
10
Readme
Discord Webhook
Description
Typescript Integration with discord webhook
version: 1.0.0
Getting started
Installation
npm install node-discord-webhook
Usage
Import module.
import {DiscordWebhook, DiscordMessageBuilder} from 'node-discord-webhook';
Initialize DiscordWebook, add Webhook url and Username to use for publish content.
const hook = new DiscordWebhook(DISCORD_WEBOOK_URL, USERNAME);
Create a message to send in channel.
const message = new DiscordMessageBuilder()
.setTitle(TITLE)
.setAuthor(AUTHOR)
.setUrl(URL)
.setDescription(DESCRIPTION)
.setImage(IMAGE)
.addField(FIELD_NAME_1, FIELD_TEXT, INLINE)
...
.addField(FIELD_NAME_N, FIELD_TEXT, INLINE)
.setThumbnail(THUMBNAIL);
Send message.
hook.sendMessage(message);
API
DiscordMessageBuilder
Methods
- setTitle(title: string)
- setAuthor(author: string, url?: string, iconUrl?: string, proxyIconUrl?: string)
- setUrl(url: string)
- setDescription(desription: string)
- setImage(url: string, proxyUrl?: string, height?: string, width?: string)
- setThumbnail(url: string, proxyUrl?: string): DiscordMessageBuilder;
- addField(name: string, value:string, inline?:boolean)
DiscordWebhook
Methods
- constructor(webhookUrl: string, username?: string);
- sendMessage(message: DiscordMessageBuilder):