-
Notifications
You must be signed in to change notification settings - Fork 2
Preparing and running your Discord Bot
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.
- Node.js 22+ installed on your computer.
- (Advanced - Technical)
discord.jsv14 or newer anddotenv - (Advanced - Technical) Docker if you are deploying to a remote server or your local 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.
- Go to the Discord Developer Portal
- On the left sidebar, click Overview and then select OAuth2
- Under the "OAuth2 URL Generator" checkbox menu, click on
botandapplications.commands - Once you check the bot box, a massive checklist called Bot Permissions will appear at the bottom of the page.
- 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
- Scroll to the very bottom of the page to find the Generated URL box.
- Click the blue Copy button next to the long web address.
- Open a brand-new tab in your internet browser, paste that link, and hit Enter.
- 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.
- Click Continue, review the permission list you configured, and click Authorize. Complete the CAPTCHA if requested.
- Go to the Discord Developer Portal
- On the left sidebar, click Overview and then select General Information
- Look for the Application ID - it's a long string of numbers on this same page
- Click the "Copy" button next to your Application ID
- Open the
.envfile on your computer and paste this ID next toAPPLICATION_ID
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:
- In the left sidebar, click OAuth2 (it should be under Overview)
- Click on Redirects or look for a section to add redirect URLs
- Click "Add Redirect" and enter:
https://discord.com - Click "Save"
This allows Discord to authorize your app with your account without errors.
How to do it:
- In the left sidebar, click Bot (under Overview)
- Under the "Bot Token" section, click "Reset Token"
- If Discord asks you to verify with 2FA (Two-Factor Authentication), complete that process
- Discord will show your token EXACTLY ONCE. Copy it.
- Open your
.envfile and paste the token next toBOT_TOKEN
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:
- First, invite Bloxlink to your Discord server.
- Visit Bloxlink's Developer API page
- Log in with your Discord account
- Add your Discord server to the list
- Once added, click the "See Key" button to reveal your server key
- Copy this key and paste it into your
.envfile next toBLOXLINK_API_KEY
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:
- 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)
- Head over to the directory/folder of the bot and type the following command and press Enter:
npm install- 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!
In the same command window, you need to run two commands. Follow these steps carefully:
Copy and paste this command into your command window, then press Enter:
npm run deployWhat'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.
Once the first command is done and there are no errors, copy and paste this command and press Enter:
npm startCongratulations! 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.
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.
- Open Terminal (or access to the remote terminal using your remote tools)
- 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