Getting Started
-
Create a new project
discord-hono is recommended to be used in a TypeScript environment.
Terminal window npm create cloudflare@latestcd YOUER_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.json
type 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 KEY
andTOKEN
, and put them.env
file.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://YOUER_PROJECT.YOUER_DOMAIN.workers.dev
in the INTERACTIONS ENDPOINT URL. -
Invite bot
Create an invite URL from the Dashboard.
YOUR_APP
>OAuth2
tab >OAuth2 URL Generator
> Check SCOPES:bot
> URLCopy
Paste the URL into the browser.