You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

discord-webhook-ts

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-webhook-ts

Client & Type definitions for the Discord Webhooks API. 📘

5.0.0
latest
Source
npmnpm
Version published
Weekly downloads
628
15.02%
Maintainers
1
Weekly downloads
 
Created
Source

Discord Webhook Types

Predefined TypeScript types and documentation for Discord webhook requests.

This package contains type definitions for all properties you can pass to a Discord webhook execution request, along with descriptions for each property.

Installation

Pull in the package from npm:

npm install discord-webhook-ts

Usage (JavaScript users)

Pull in the webhook client and enjoy auto-completion from your IDE.

import DiscordWebhook from 'discord-webhook-ts';

// Pass in your Discord webhook URL.
const discordClient = new DiscordWebhook('https://discordapp.com/api/webhooks/4752...');
Execute a webhook
discordClient.execute({
    embeds: [
        {
            title: 'Some title',
            description: 'Some description',
        },
        {
            fields: [
                {
                    name: 'Some field',
                    value: 'Some field value',
                }
            ]
        }
    ]
}).then((response) => {
    console.log('Successfully sent webhook.')
})
Get the current webhook information
discordClient.get().then((response) => console.log(response.data))
Update the current webhook
discordClient.modify({
    name: 'new name',
    avatar: 'https://via.placeholder.com/150',
}).then((response) => {
    console.log('Successfully updated webhook!');
})

Usage (TypeScript users)

Pull in and attach the Discord Webhook.input.POST interface to your request object.

import DiscordWebhook, { Webhook } from 'discord-webhook-ts';

// Pass in your Discord webhook URL.
const discordClient = new DiscordWebhook('https://discordapp.com/api/webhooks/4752...');

const requestBody: Webhook.input.POST = {
    embeds: [
        {
            title: 'Some title',
            description: 'Some description',
        },
        {
            fields: [
                {
                    name: 'Some field',
                    value: 'Some field value',
                }
            ]
        }
    ]
};

discordClient.execute(requestBody) // -> Promise<AxiosResponse>

Contributing

Contributions are more than welcome! If you spot a missing or incorrectly formatted or documented property, just submit a pull request.

License

This repository is licensed under the ISC license.

Copyright (c) 2019, Jørgen Vatle.

Keywords

TypeScript

FAQs

Package last updated on 05 Dec 2021

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