Skip to content

A Cloudflare handler and sample app for Discord http endpoint applications

License

Notifications You must be signed in to change notification settings

NikanDevs/discord-cloudflare-handler

Repository files navigation

Discord Cloudflare handler with workers

Discord bot handler with cloudflare workers (also known as discord-http-endpoint-applications)

Resources

1. Making a Discord application

You have to make a Discord application in Discord's developer portal

  • Application scopes: bot and application.commands

2. Create a cloudflare worker

3. Configuring wrangler.toml

Replace values for name with your worker name and account_id with your cloudflare's account ID

4. Saving your project environment variables

$ 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

5. Register application commands

You need to make a .env as shown in .env.example and replace all of your environment variables with values

$ npm run register

6. Set the interaction endpoint URL for your application

Go to Discord's developer portal, and select your application.

  1. Select the General Information tab
  2. Put your worker route (https://WORKER_NAME.ACCOUNT_SUBDOMAIN.workers.dev) in the interaction endpoint URL section

7. Deploy and publish

$ npm run deploy

Preview

preview

This README is an extended version of discord/cloudflare-sample-app/README.md