Skip to main content

Prerequisites

Before installing the bot, ensure you have the following:

Node.js

Version 18.0.0 or higher

Discord bot token

From Discord Developer Portal

Create a Discord bot

If you haven’t created a Discord bot yet:
1

Visit Discord Developer Portal

Go to discord.com/developers/applications and click “New Application”
2

Create bot user

Navigate to the “Bot” section and click “Add Bot”. Confirm by clicking “Yes, do it!”
3

Copy bot token

Under the bot username, click “Reset Token” and copy the token. Keep this secret!
Never share your bot token publicly. Anyone with access to your token can control your bot.
4

Enable required intents

Scroll down to “Privileged Gateway Intents” and enable:
  • Guilds
  • GuildMessages
5

Invite bot to your server

Go to the “OAuth2” > “URL Generator” section:
  • Select scope: bot and applications.commands
  • Select permissions: Send Messages, Embed Links, Use External Emojis
  • Copy the generated URL and open it in your browser to invite the bot

Installation steps

1

Clone the repository

Clone the bot repository to your local machine:
git clone https://github.com/yourusername/streamer-alerts-bot.git
cd streamer-alerts-bot
2

Install dependencies

Install the required Node.js packages:
npm install
This will install the following core dependencies:
  • discord.js (v14.14.1+) - Discord API wrapper
  • dotenv (v16.3.1+) - Environment variable management
3

Configure environment variables

Copy the example environment file:
cp .env.example .env
Edit .env and add your Discord credentials:
DISCORD_TOKEN=your_bot_token_here
CLIENT_ID=your_client_id_here
See the Configuration page for detailed information about environment variables.
4

Deploy slash commands

Register the bot’s slash commands with Discord:
npm run deploy
For instant command deployment during development, add a GUILD_ID to your .env file. Without it, global deployment takes up to 1 hour to propagate.
5

Start the bot

Launch the bot:
npm start
You should see output indicating successful login:
[INFO] Logging in...
[INFO] Logged in as YourBotName#1234
[INFO] Started polling for 0 streamers across 1 guilds

Development mode

For development, use these additional commands:
# Run with hot reload using tsx watch
npm run dev

Verify installation

Once the bot is running, verify it works:
1

Check bot status

In Discord, verify your bot appears online in the member list
2

Test ping command

Type /ping in any channel the bot has access to. You should receive a response with the bot’s latency
3

Add a streamer

Try adding a streamer with /streamer add platform:Twitch username:ninja
If commands don’t appear, wait a few minutes for Discord to register them, or restart your Discord client.

Troubleshooting

Bot doesn’t respond to commands

  • Verify the bot has the required permissions in your server
  • Check that slash commands were deployed with npm run deploy
  • Ensure the bot token and client ID in .env are correct
  • Try restarting your Discord client to refresh the command cache

”DISCORD_TOKEN is not set” error

The bot validates environment variables on startup. From src/index.ts:
const token = process.env.DISCORD_TOKEN;

if (!token) {
  logger.error("DISCORD_TOKEN is not set in environment variables");
  process.exit(1);
}
Ensure your .env file exists and contains a valid DISCORD_TOKEN.

Module not found errors

If you see module resolution errors:
# Clean install dependencies
rm -rf node_modules package-lock.json
npm install

Next steps

Configuration

Learn about environment variables and bot permissions

Usage guide

Discover how to use all bot commands effectively

Build docs developers (and LLMs) love