How to Make a Discord Bot: Beginner’s Guide

By Shah Rukh, software developer · Last updated:

A Discord bot is a small program that logs in to Discord like a member and responds to commands and events: welcoming people, moderating chat, running polls and more. This guide walks you through making one from scratch, even if you’ve never coded.

What you need

Step 1: Create the application

  1. Go to the Discord Developer Portal and log in.
  2. Click New Application, type a name and create it.
  3. On General Information, copy the Application ID. You’ll need it for the invite link.

Step 2: Get your bot token

  1. Open the Bot tab.
  2. Click Reset Token, then Copy.

The token is your bot’s password. Never share it or post it online. If it leaks, reset it straight away.

Step 3: Turn on the intents you need

Intents tell Discord which events your bot wants to receive. On the Bot tab, under Privileged Gateway Intents:

Step 4: Get the code

The quickest way is the Discord bot maker: tick the features you want and download a ready-to-run project. Or start with this minimal bot in a file called bot.py:

import os
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix=commands.when_mentioned, intents=discord.Intents.default())

@bot.event
async def on_ready():
    await bot.tree.sync()
    print(f"Logged in as {bot.user}")

@bot.tree.command(description="Say hello")
async def hello(interaction: discord.Interaction):
    await interaction.response.send_message(f"Hello, {interaction.user.mention}!")

bot.run(os.environ["DISCORD_TOKEN"])

Install the library with python -m pip install discord.py.

Step 5: Invite the bot to your server

Open this link, with your Application ID in place of the capitals:

https://discord.com/oauth2/authorize?client_id=YOUR_APPLICATION_ID&scope=bot+applications.commands&permissions=85056

Pick your server and click Authorize. The applications.commands part is what allows slash commands.

Step 6: Run it

Set your token and start the bot. With a project from the bot maker, put the token in the .env file and double-click start.bat. When you see “Logged in as…”, type / in your server and try a command.

Common problems

ProblemFix
Slash commands don’t appearWait up to an hour for global commands, or sync to one server for instant updates. Check you invited the bot with applications.commands.
“Improper token” errorCopy the token again from the Bot tab; make sure there are no spaces or quotes around it.
“Privileged intents” errorTurn on the intents from Step 3 and save.
Bot can’t kick, ban or give rolesDrag the bot’s role above the roles it manages in Server Settings → Roles.
Bot goes offlineIt only runs while the program is open. Host it on a server to keep it online.

Rules to follow

Bots must follow Discord’s Terms of Service and Developer Policy. In short: don’t spam, don’t send unsolicited mass DMs, don’t collect members’ data without telling them, and don’t automate normal user accounts (“self-bots”).

Want your exact number? Use the free Discord Bot Maker. It takes about 30 seconds.

Frequently asked questions

Is making a Discord bot free?

Yes. Creating a bot and using Discord’s API is free. You only pay if you choose paid hosting to keep it online all the time.

Which language is best for Discord bots?

Python (discord.py) and JavaScript (discord.js) are the two most popular. Python is usually easier for beginners.

Can I make a bot on my phone?

You can create the application on a phone, but running the bot needs a computer or server.

How do I keep my bot online 24/7?

Run it on a machine that’s always on, such as a cloud server or a Raspberry Pi.

More guides

📘

How to Make a Wi-Fi QR Code

Let guests join your Wi-Fi by scanning a code, no password typing.

Related tools

🤖

Discord Bot Maker

Build a custom Discord bot without coding.

🔳

QR Code Generator

Free QR codes for links, Wi-Fi, text and contacts.

🎨

Color Picker & Palette

HEX, RGB and HSL codes plus matching palettes.