1.0.1 • Published 1 year ago

node-discord-webhook v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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):

License

MIT

1.0.1

1 year ago

1.0.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago