A slash-create template, using Cloudflare Workers. This project is based on https://github.com/Snazzah/slash-create-worker
To get started with this project, clone the repository:
git clone https://github.com/towsifkafi/cloudflare-workers-discord.gitAfter cloning, install the dependencies using npm:
npm installMake sure to sign up for a Cloudflare Workers account in a browser before continuing. Install wrangler with npm:
npm install -D wrangler@latestRead more about installing wrangler.
Afterwards, run wrangler login to login to your Cloudflare account with OAuth:
wrangler loginYou can enter in environment secrets with wrangler secret put, here are the keys that are required to run this:
npx wrangler secret put DISCORD_APP_ID
npx wrangler secret put DISCORD_PUBLIC_KEY
npx wrangler secret put DISCORD_BOT_TOKENTo run this locally, create a .env file and a .dev.vars file based on the provided examples, then you can run wrangler dev to start a local dev environment and use something like ngrok to tunnel it to a URL.
To sync commands in the development environment, run npm run sync:dev (or yarn sync:dev).
Note: When you create a command, make sure to include it in the array of commands in
./src/commands/index.ts.
To sync to production, run npm run sync. To publish code to a worker, run npm run deploy.