Skip to content

Preparing and running your Discord Bot

Corey edited this page Jul 8, 2026 · 3 revisions

Before you can start using your bot, you'll need to set up several things on Discord and configure some files on your computer. Don't worry, this guide will walk you through each step carefully.

Prerequisites

  • Node.js 22+ installed on your computer.
  • (Advanced - Technical) discord.js v14 or newer and dotenv
  • (Advanced - Technical) Docker if you are deploying to a remote server or your local server.

Prepare your bot

"Step 0": Inviting your bot to the server

This is quite obvious ready, but you need to invite your bot to the server for you to be able to interact with it.

  1. Go to the Discord Developer Portal
  2. On the left sidebar, click Overview and then select OAuth2
  3. Under the "OAuth2 URL Generator" checkbox menu, click on bot and applications.commands
  4. Once you check the bot box, a massive checklist called Bot Permissions will appear at the bottom of the page.
  5. Look under the columns and check these boxes:
    • General Permissions: View Channels
    • Text Permissions: Send Messages, Send Messages in Threads, Attach Files, Attach Links, Read Message History, Use External Emojis, Add Reactions
  6. Scroll to the very bottom of the page to find the Generated URL box.
  7. Click the blue Copy button next to the long web address.
  8. Open a brand-new tab in your internet browser, paste that link, and hit Enter.
  9. A Discord pop-up window will appear. Under Add to Server, click the dropdown menu and select the server you want to add it to.
  10. Click Continue, review the permission list you configured, and click Authorize. Complete the CAPTCHA if requested.

Step 1: Getting the Application ID

  1. Go to the Discord Developer Portal
  2. On the left sidebar, click Overview and then select General Information
  3. Look for the Application ID - it's a long string of numbers on this same page
  4. Click the "Copy" button next to your Application ID
  5. Open the .env file on your computer and paste this ID next to APPLICATION_ID

Step 2: Set up your Redirect URL

What is this? A redirect URL tells Discord where to send users after they authorize your app. This is necessary for the authorization process to work properly.

How to do it:

  1. In the left sidebar, click OAuth2 (it should be under Overview)
  2. Click on Redirects or look for a section to add redirect URLs
  3. Click "Add Redirect" and enter: https://discord.com
  4. Click "Save"

This allows Discord to authorize your app with your account without errors.

Step 3: Getting your Bot Token

How to do it:

  1. In the left sidebar, click Bot (under Overview)
  2. Under the "Bot Token" section, click "Reset Token"
  3. If Discord asks you to verify with 2FA (Two-Factor Authentication), complete that process
  4. Discord will show your token EXACTLY ONCE. Copy it.
  5. Open your .env file and paste the token next to BOT_TOKEN

Step 4: Add Bloxlink and get the API Key

What is this? Bloxlink is a service that helps connect Discord accounts to Roblox accounts. To get your Roblox username from your Discord account, we need to use Bloxlink's API.

How to do it:

  1. First, invite Bloxlink to your Discord server.
  2. Visit Bloxlink's Developer API page
  3. Log in with your Discord account
  4. Add your Discord server to the list
  5. Once added, click the "See Key" button to reveal your server key
  6. Copy this key and paste it into your .env file next to BLOXLINK_API_KEY

Step 5: Install the necessary modules

What is this? Modules (also called "packages" or "libraries") are pre-written code that helps your bot function. You need to download them to your computer before running the bot.

How to do it:

  1. On your computer, open your command interpreter:
    • Windows: Open Command Prompt (search for "cmd" in the Start menu)
    • Mac: Open Terminal (search for "terminal" in your search bar)
    • Linux: Open your terminal application (If you are using this, I believe that you know what you are doing anyways)
  2. Head over to the directory/folder of the bot and type the following command and press Enter:
npm install
  1. Wait for the installation to complete. You should see messages about downloading and installing packages

Once all steps are complete, your bot is ready to go!

Running the bot

Running locally on your PC

In the same command window, you need to run two commands. Follow these steps carefully:

First command - Tell Discord about your bot's commands

Copy and paste this command into your command window, then press Enter:

npm run deploy

What's happening: This command tells Discord about all the commands your bot can do. Wait for it to finish - you'll see some messages appear. This usually takes a few seconds.

Second command - Start your bot

Once the first command is done and there are no errors, copy and paste this command and press Enter:

npm start

Congratulations! Your bot is now running and ready to use.

⚠️ Important for Windows users: Do NOT close this command window while your bot is running. If you close it, your bot will stop working. Keep it open the entire time you want your bot to be active. You can minimize it if you want it out of the way. Only close it when you're completely done and want to turn the bot off.

Deploying your bot to a remote server (Advanced)

If you are reading this part, I assume that you know what you are doing. This repository uses Docker to deploy the bot as a container.

  1. Open Terminal (or access to the remote terminal using your remote tools)
  2. Run these following commands:
cd bot                                                                                          # if you are not in the bot directory
docker build -t phighting-discord-widgets .                                                     # build from dockerfile
docker run -d --name phighting-discord-widgets --env-file .env phighting-discord-widgets
docker logs phighting-discord-widgets                                                           # enable logging on your console