Discord bot handler with cloudflare workers (also known as discord-http-endpoint-applications)
You have to make a Discord application in Discord's developer portal
- Application scopes:
bot
andapplication.commands
- Visit the Cloudflare dashboard
- Click on the
Workers
tab, and create a new service using the same name as your Discord bot - Make sure to install the Wrangler CLI and set it up.
Replace values for name
with your worker name and account_id
with your cloudflare's account ID
$ wrangler secret put DISCORD_TOKEN
$ wrangler secret put DISCORD_PUBLIC_KEY
$ wrangler secret put DISCORD_APPLICATION_ID
$ wrangler secret put DISCORD_TEST_GUILD_ID
- After running each command, the wrangler asks you for the value of the variable, type the value in there
- Note: You have to use
npx wrangler secret put ...
if you are using macOS
You need to make a .env
as shown in .env.example
and replace all of your environment variables with values
$ npm run register
Go to Discord's developer portal, and select your application.
- Select the
General Information
tab - Put your worker route (https://WORKER_NAME.ACCOUNT_SUBDOMAIN.workers.dev) in the
interaction endpoint URL
section
$ npm run deploy
This README is an extended version of discord/cloudflare-sample-app/README.md