Socket
Socket
Sign inDemoInstall

discord-webhook-ts

Package Overview
Dependencies
2
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    discord-webhook-ts

Client & Type definitions for the Discord Webhooks API. 📘


Version published
Weekly downloads
198
decreased by-54.9%
Maintainers
1
Install size
415 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 05 Dec 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc