Discord.https is a robust, modular library for implementing Discord HTTP interactions.
It handles various interactions, adds a layer of wrapper over raw interactions with rich utility methods, and organizes them into modular routes, making your bot's code cleaner, easier to understand, and easier to maintain. It works seamlessly in both serverless and persistent server environments.
๐ Documentation: https://discordhttps.js.org
Need help? Join us on discord https://discord.gg/pSgfJ4K5ej
You can initialize a project via CLI:
npx create-discord-https@latest
Or, manually:
import Client from "discord.https";
import NodeAdapter from "@discordhttps/nodejs-adapter";
const client = new Client({
token: "YOUR BOT TOKEN",
publicKey: "YOUR PUBLIC KEY",
httpAdapter: new NodeAdapter(),
});
client.command(
(builder) => builder.setName("hi").setDescription("reply hello!"),
async (interaction) => await interaction.reply("hello!")
);
await client.listen("interactions", 3000, () => {
console.log(
"Listening for interactions on port 3000 at the /interactions endpoint"
);
});
Note: Looking for volunteer contributors! If you are interested, join us on Discord: https://discord.gg/pSgfJ4K5ej
Note: Utility methods such as
.editReply() and .deferReply() are currently in development, so you wonโt need to manually handle the raw response object in the future.
Note: Utility methods were initially planned to closely follow Discord.js. However, since HTTP interactions are mostly used in a serverless environment, instead of having many layers of objects like Discord.js, an Eris-like approach will be adopted to keep the utilities minimal and lightweight.
Breaking Update (latest note): The goal was to stay within the web-standard V8 engine, but
@discord/rest
heavily depends on the Node.js environment. There are two choices: either use@discord/rest
or build a custom REST handler. For now,@discord/rest
will be used. The focus is on the Edge network, primarily Cloudflare. However, Cloudflare recently added native Node.js support. Previously, Node.js support was polyfilled, which can be inefficient for servers due to extra overhead. Now, Node.js support is native. Hence, from now on, the focus will be on Node.js APIs instead of web-standard/browser-context APIs.
Note: You can get this reference implementation directly via CLI, see Initializing Your Project โ Using CLI.
You can view example/reference implementations here:
npx create-discord-https@latest
Follow the prompts to set up your project.
Install discord.https along with the adapter for your server environment.
npm install discord.https @discordhttps/nodejs-adapter
npm install discord.https @discordhttps/cloudflare-adapter
npm install discord.https @discordhttps/vercel-adapter
npx create-app
command