dressed
Version:
A sleek, serverless-ready Discord bot framework.
27 lines (26 loc) • 1.7 kB
TypeScript
import type { CommandRunner, ComponentRunner, EventRunner } from "../types/handlers.ts";
import type { CommandData, ComponentData, EventData, ServerConfig } from "../types/config.ts";
import { type Server } from "node:http";
/**
* Starts a server to handle interactions.
* @returns The server instance
*/
export declare function createServer(commands: CommandRunner | CommandData[], components: ComponentRunner | ComponentData[], events: EventRunner | EventData[], config: ServerConfig): Server;
/**
* Handles a request from Discord.
* @param req The request from Discord
* @param commands A list of commands or the function to run a command
* @param components A list of components or the function to run a component
* @param events A list of events or the function to run an event
* @param config Configuration for your server
* @returns The response to send back to Discord
*/
export declare function handleRequest(req: Request, commands: CommandRunner | CommandData[], components: ComponentRunner | ComponentData[], events: EventRunner | EventData[], config?: ServerConfig): Promise<Response>;
/**
* Runs an interaction, takes functions to run commands/components/middleware and the request body
*/
export declare function handleInteraction(commands: CommandRunner | CommandData[], components: ComponentRunner | ComponentData[], json: ReturnType<typeof JSON.parse>, middleware: ServerConfig["middleware"]): 200 | 202 | 404;
/**
* Runs an event, takes a function to run events/middleware and the request body
*/
export declare function handleEvent(events: EventRunner | EventData[], json: ReturnType<typeof JSON.parse>, middleware: ServerConfig["middleware"]): 200 | 202 | 404;