Skip to content

Getting Started

  1. Create a new project

    Terminal window
    npm create cloudflare@latest
    cd YOUER_PROJECT
    npm i discord-hono
    npm i -D discord-api-types # When using TypeScript
    npm i -D dotenv # When using 'npm run register'

    Copy the linked files.

    Add to package.json type and scripts.

    package.json
    "type": "module",
    "scripts": {
    "register": "tsc && node dist/register.js",
    },
  2. Setup discord bot - Discord Docs

    Create a New Application from Dashboard.
    Copy your APPLICATION ID, PUBLIC KEY and TOKEN, and put them .dev.vars file.

    .dev.vars
    DISCORD_APPLICATION_ID: "..."
    DISCORD_PUBLIC_KEY: "..."
    DISCORD_TOKEN: "..."
    DISCORD_TEST_GUILD_ID: "..."

    Storing secrets.

    Terminal window
    npx wrangler secret put DISCORD_APPLICATION_ID
    npx wrangler secret put DISCORD_PUBLIC_KEY
    npx wrangler secret put DISCORD_TOKEN

    Register commands and deploy.

    Terminal window
    npm run register
    npm run deploy

    Set endpoint url.

    Enter https://YOUER_PROJECT.YOUER_DOMAIN.workers.dev in the INTERACTIONS ENDPOINT URL.

  3. Invite bot

    Create an invite URL from the Dashboard.
    YOUR_APP > OAuth2 tab > OAuth2 URL Generator > Check SCOPES: bot > URL Copy
    Paste the URL into the browser.

Examples