@electr0zed/discord-interactions-cf
v0.15.23
Published
Framework for accepting Interactions from Discord on Cloudflare workers
Downloads
70
Readme
@electr0zed/discord-interactions-cf
A minimal and performant module for handling Discord Interactions in Cloudflare Workers. Designed for speed, simplicity, and ease of deployment.
🚀 Installation
npm install @electr0zed/discord-interactions-cf🔧 Environment Variables
Set the following environment variables in your Cloudflare Worker:
PUBLIC_KEY– (required) Your bot’s public key (used to verify incoming requests)CLIENT_ID– (required) Your bot’s client IDTOKEN– (optional) Bot token, only needed for command registration
⚙️ Compatibility Flags
Make sure to enable the nodejs_compat flag in your wrangler.toml or wrangler.jsonc config:
"compatibility_flags": ["nodejs_compat"]🌐 Worker URL
The public URL of your deployed Cloudflare Worker is the URL you give to Discord as your interaction endpoint.
To register commands, make a GET or POST request to:
<your-worker-url>/registerwith the following header:
Authorization: Bearer <your-bot-token>Ensure your bot token (
TOKEN) is set as an environment variable and passed in the request header as shown above.
📦 Status
This package is usable, but still in alpha. Expect breaking changes as the API evolves.
📁 Examples
See the examples/ directory for working usage, command registration, and response handling.
