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

webhook-bot-js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webhook-bot-js

A JavaScript library for creating Webhook-Based Discord Bots

0.1.6
latest
Source
npmnpm
Version published
Weekly downloads
22
214.29%
Maintainers
1
Weekly downloads
 
Created
Source

webhook-bot-js

A JavaScript library for creating Webhook-Based Discord Bots

Installation:

npm install webhook-bot-js
or
yarn add webhook-bot-js

Example:

import { WebhookServer, CommandOption, getStringOption, CommandResponse } from "webhook-bot-js";

//create server by providing information about your application
const server = new WebhookServer({
    application_id: "APPLICATION_ID",
    token: "BOT_TOKEN",
    public_key: "APPLICATION_PUBLIC_KEY",
});

//register a slash command
server.registerSlashCommand({
    name: "hello",
    description: "Greet someone",
    options: [
        {
            name: "name",
            description: "The name of the person to greet",
            type: CommandOption.STRING,
            required: true,
        },
    ],
    execute: (interaction) => {
        const name = getStringOption(interaction, "name");
        return {
            type: CommandResponse.Message,
            data: {
                content: `Hello ${name}`,
            },
        };
    },
});

//register commands against discords api
server.pushGlobalApplicationCommands();

//start server
server.start();

More examples can be found in the examples directory

Keywords

discord

FAQs

Package last updated on 23 Jun 2022

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