Skip to content

discordhttps/discord.https

Repository files navigation

Logo

Discord npm version License Downloads Docs

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

Initilize discord.https

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"
  );
});

Project Updates

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.

Examples

Note: You can get this reference implementation directly via CLI, see Initializing Your Project → Using CLI.

You can view example/reference implementations here:

Initializing Your Project

Using CLI (Recommended)

npx create-discord-https@latest

Follow the prompts to set up your project.

Manual Installation

Install discord.https along with the adapter for your server environment.

Node.js

npm install discord.https @discordhttps/nodejs-adapter

Cloudflare

npm install discord.https @discordhttps/cloudflare-adapter

Vercel

npm install discord.https @discordhttps/vercel-adapter

Documentation

Todo for v4

  • Implement tests
  • Build channel, guild, etc wrapper
  • Build a simplified npx create-app command
  • Build interaction wrapper
  • HTTP adapters to support most hosting environments. Currently implemented: Node.js adapter for Node.js runtime and Cloudflare adapter for V8 isolates runtime
  • Examples(currently outdated, requires update)

About

Discord.https is a robust, modular library for implementing Discord HTTP interactions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published