Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 2.23 KB

File metadata and controls

36 lines (26 loc) · 2.23 KB

Getting Started

This app requires more setup to run locally than a traditional web app due to Discord applications needing a public endpoint. For local testing, we must create a new application with Discord and create an HTTP tunnel between our local dev server and a public endpoint. The only prerequisite is having pnpm installed.

Setting up the bot

  1. Create a discord application for development on the Discord Developer Dashboard (you can call it shorter-dev or something similar):

    1. After creating your app, copy your Public Key and Application ID and save them somewhere safe.
    2. Go to the Bot tab and copy your token, again saving it somewhere safe.
  2. cd into the bot package directory.

  3. Run openssl rand -hex 32 to generate your SHORTER_API_KEY.

  4. Create a local .dev.vars file by running cp .dev.vars.example .dev.vars and paste your newly obtained credentials into it.

  5. Run pnpm invite and add the bot to a server you'd like to test it in.

  6. Run pnpm register to register the app's commands with Discord.

  7. Start a local dev server and create an HTTP tunnel:

    1. Run pnpm dev to start a local dev server on localhost:8787.
    2. Run pnpm tunnel in a different terminal, it should display a public URL that forwards the dev server you started in the previous step.
    3. Visit the URL in your browser. If you did everything correctly, you should see the message Hi!.
  8. Paste your public URL into the Interactions Endpoint URL field back on the Discord Developer Dashboard.

Setting up the shortlink service

  1. cd into the service package directory.
  2. Create a local .dev.vars file by running cp .dev.vars.example .dev.vars and paste your SHORTER_API_KEY into it.
  3. Run pnpm dev in a third terminal to start a local dev server on localhost:8788.

Submitting a PR

Make sure you run pnpm check in both packages before submitting. You can run pnpm check:write to apply any fixes the tool finds.

References