How to Make a Discord Bot 2026: From Zero to a Running Bot

Published on

A practical guide to making a Discord bot in 2026, covering the developer portal, choosing a library, writing your first command, intents, and hosting it.

Making a Discord bot is one of the most popular beginner coding projects, and it is very approachable. This guide takes you from an empty developer portal to a bot that responds to commands.

Step 1: Register the Bot

Start in the Discord developer portal. Create a new application, then add a bot user to it. Set the bot name and avatar, and copy the bot token, which your code uses to log in. Keep that token private.

Step 2: Choose a Library

You write a bot in a programming language using a Discord library. The most common choices are:

  • JavaScript with discord.js, very popular and well documented
  • Python with discord.py, beginner friendly and clean

Pick the language you are most comfortable with. JavaScript and Python are the two easiest starting points.

Step 3: Set Up Your Project

For a JavaScript bot, install Node.js, create a project folder, and install the library:

npm init -y
npm install discord.js

For Python, install Python and the library:

pip install discord.py

Store your token in an environment variable or a config file you keep out of version control, never hardcoded in shared code.

Step 4: Write Your First Bot

A minimal discord.js bot that replies to a command looks like this:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent
  ]
});

client.on('messageCreate', (msg) => {
  if (msg.content === '!ping') msg.reply('Pong');
});

client.login(process.env.TOKEN);

This logs in, listens for messages, and replies Pong when someone types !ping.

Step 5: Enable Intents

If your bot reads message content, enable the message content intent in the bot settings on the developer portal. Intents must match what your code requests, or the bot will fail to start.

Step 6: Invite the Bot

Build an OAuth2 invite link with the bot scope and the permissions your bot needs, then open it to add the bot to your server. Use slash commands by adding the applications.commands scope for modern command handling.

Step 7: Keep It Online with Hosting

Your bot only runs while the program is running. To keep it online all the time, host it on a small server or VPS rather than your home computer. A lightweight always on host keeps the bot responsive day and night.

Tips

Start small with one command and grow from there. Use slash commands for a modern feel. Never expose your token, and regenerate it if it leaks.

FAQ

What language should I use for a Discord bot? JavaScript with discord.js or Python with discord.py are the two best beginner options.

Do I need to host a Discord bot? Yes, to keep it online all the time. Running it on your own computer only works while that computer is on.

Why does my bot not respond? Often missing intents or an invalid token. Enable the right intents and check the token.

Related: Discord developer portal guide, Discord server setup, How to find Discord servers

Keep Your Bot Online 24/7

Reliable Discord bot hosting powered by enterprise AMD Ryzen 9 hardware. Start free, upgrade anytime with guaranteed uptime.