dressed
Version:
A sleek, serverless-ready Discord bot framework.
50 lines (36 loc) • 1.95 kB
Markdown
<div align="center">
<img src="https://raw.githubusercontent.com/Inbestigator/dressed/main/www/public/dressed.webp" alt="Dressed logo" width="128" />
<h1>Dressed</h1>
</div>
Dressed is a Discord bot library that allows you to host a bot using the
[interactions endpoint](https://discord.com/developers/docs/interactions/overview#configuring-an-interactions-endpoint-url) system for Discord.
Discord will send `POST` requests to your bot, instead of the websocket system that other libraries utilize.
One cool feature of Dressed is that you can make **dynamic component IDs**, so that you only need to write one component handler for many different scenarios. 👉 [See more](https://dressed.js.org/docs/components#dynamic-component-ids)
You can find examples of bots ready to deploy on
[Cloudflare Workers](https://workers.cloudflare.com/), [Vercel](https://vercel.com), and [Deno Deploy](https://deno.com/deploy) in
[this repo](https://github.com/Inbestigator/dressed-examples).
## 🚀 Usage
```sh
bun add dressed
```
```ts
// src/commands/ping.ts
import type { CommandConfig, CommandInteraction } from "dressed";
export const config = {
description: "Checks the API latency",
} satisfies CommandConfig;
export default async function (interaction: CommandInteraction<typeof config>) {
const start = Date.now();
const res = await interaction.deferReply({ ephemeral: true, with_response: true });
const delay = Date.parse(res.resource?.message?.timestamp ?? "") - start;
await interaction.editReply(`🏓 ${delay}ms`);
}
```
You can then build and run the bot with:
```sh
bun dressed build -ir
bun .dressed
```
For more information on how to create a simple bot, check out [the getting started guide](/docs/guide/getting-started).
Dressed includes a [Node HTTP](https://nodejs.org/api/http.html) server out of the box.
If you'd prefer to create your own, all the functions you need are available within `dressed/server`.