Getting Started
-
Create a new project
discord-hono is recommended to be used in a TypeScript environment.
Terminal window npm create cloudflare@latestcd YOUR_PROJECTnpm i discord-hononpm i -D discord-api-types # When using TypeScript# npm i -D @types/node # As neededCopy the linked files.
Directorysrc
- .env.example Rename file to .env
- package.json
- tsconfig.json When using TypeScript
- …
Add to
package.jsontype and scripts.package.json "type": "module","scripts": {"register": "tsc && node --env-file=.env dist/register.js",}, -
Setup discord bot - Discord Docs
Create a New Application from Dashboard.
Copy yourAPPLICATION ID,PUBLIC KEYandTOKEN, and put them.envfile.Storing secrets.
Terminal window npx wrangler secret put DISCORD_APPLICATION_IDnpx wrangler secret put DISCORD_PUBLIC_KEYnpx wrangler secret put DISCORD_TOKENRegister commands and deploy.
Terminal window npm run registernpm run deploySet endpoint url.
Enter
https://YOUR_PROJECT.YOUR_DOMAIN.workers.devin the INTERACTIONS ENDPOINT URL. -
Invite bot
Create an invite URL from the Dashboard.
YOUR_APP>OAuth2tab >OAuth2 URL Generator> Check SCOPES:bot> URLCopy
Paste the URL into the browser.