Quick Start
Install
Section titled “Install”pip install cordlessuv add cordlessScaffold
Section titled “Scaffold”mkdir my-bot && cd my-botcordless init my-botThis asks how Discord should reach your bot: a direct Lambda Function URL (recommended, lower latency) or an API Gateway HTTP API (only needed if you want a custom domain later). Pick 1 unless you already know you want a custom domain.
This creates lambda_function.py, cordless.toml, and .env.example.
lambda_function.py
import os
from cordless import Cordless
bot = Cordless(public_key=os.environ.get("DISCORD_PUBLIC_KEY"))
@bot.command("hello", description="Say hello")async def hello(ctx, name: str = "world"): await ctx.send(f"Hello, {name}!")
handler = bot.handler()Typed parameters become Discord options automatically: name: str = "world" registers an optional string option.
Configure
Section titled “Configure”Fill in your credentials. Create a .env file in your project root (cordless loads it automatically for all commands and merges it into your Lambda’s environment on deploy):
.env
DISCORD_PUBLIC_KEY=your_public_keyDISCORD_BOT_TOKEN=your_bot_tokencordless.toml
[deploy]function = "my-bot"region = "us-east-1"Test locally
Section titled “Test locally”cordless devRuns your bot on localhost with hot reload. With cloudflared installed it also opens a public tunnel, paste that URL into your app’s Interactions Endpoint URL and test in Discord without deploying anything. Deferred handlers run in-process, so the whole flow works.
Install cloudflared
Section titled “Install cloudflared”brew install cloudflaredwinget install Cloudflare.cloudflaredcurl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg > /dev/nullecho "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main" | sudo tee /etc/apt/sources.list.d/cloudflared.listsudo apt update && sudo apt install cloudflaredparu -S cloudflaredOr download a binary directly from the Cloudflare releases page.
Deploy
Section titled “Deploy”cordless deploy --registerOne command: cordless creates the Lambda, its endpoint (a Function URL by default), and the IAM role, registers your slash commands with Discord, and prints your bot’s URL. Paste it into your Discord app’s Interactions Endpoint URL and run /hello.
You can also register separately with cordless register, add --guild-id during development for instant propagation.
