webhook-bot-js
Version:
A JavaScript library for creating Webhook-Based Discord Bots
54 lines (53 loc) • 1.79 kB
TypeScript
/// <reference types="node" />
import { MessageCommand, SlashCommand, UserCommand } from '../core/commandTypes';
import EventEmitter from 'node:events';
export declare class WebhookServer extends EventEmitter {
private app;
private rest;
readonly port: number;
private readonly token;
private readonly application_id;
private readonly public_key;
/**
* Creates a new WebhookServer
* @param options Options for the Server
*/
constructor(options?: ServerOptions);
/**
* Adds a SlashCommand to be registered.
* This method does NOT interact with Discord in any way.
* @param command The SlashCommand
*/
registerSlashCommand(command: SlashCommand): void;
/**
* Adds a UserCommand to be registered.
* This method does NOT interact with Discord in any way.
* @param command The UserCommand
*/
registerUserCommand(command: UserCommand): void;
/**
* Adds a MessageCommand to be registered.
* This method does NOT interact with Discord in any way.
* @param command The MessageCommand
*/
registerMessageCommand(command: MessageCommand): void;
/**
* Overwrites all global Application Commands
*/
pushGlobalApplicationCommands(): Promise<void>;
/**
* Overwrites all Application Commands in the specified guild
*/
pushGuildApplicationCommands(guildId: string): Promise<void>;
/**
* Runs the Server on "/" on the specified Port.
* Incoming request are automatically verified using the provided public key
*/
start(): void;
}
export declare type ServerOptions = {
port?: number;
token?: string;
application_id?: string;
public_key?: string;
};