What You Are Going to Build
By the end of this walkthrough you will have a real Discord bot, live in a server, responding to a command you typed into existence. Not a toy in a tutorial video - a bot you own, that you can point at any job you want. And you will build it with Claude Code, which means you describe what you want in plain English and Claude writes the code.
I want to be straight with you about the shape of this. A Discord bot has two halves. One half lives on Discord's side - registering the bot and getting a secret token. The other half is the code that logs in with that token and reacts to messages. Claude Code handles the second half almost entirely. Your job is mostly the first half, plus telling Claude what the bot should do. If you have ever wanted to see how far the tool actually goes, this is a great first real project.
What You Need Before You Start
You need three things, and all of them are free. First, a Discord account and a server you have permission to manage - your own test server is perfect. Second, Claude Code installed on your machine. Third, about thirty minutes. That is the whole list. You do not need to know Python or JavaScript, and you do not need to have built anything before.
- A Discord account and a server you can add a bot to.
- Claude Code installed and open, in the desktop app or the terminal.
- An empty folder on your machine for the project to live in.
Step 1: Create the Bot in Discord's Developer Portal
Everything starts on Discord's side. Go to the Discord Developer Portal, create a new application, and give it a name - this is your bot's identity. Inside that application there is a Bot section. Open it and you will find a button to reveal a token. That token is the password your code uses to log in as the bot. Copy it and keep it somewhere private for a minute.
While you are in the Bot section, turn on the message content intent. This is the permission that lets your bot actually read the messages people send, and beginners get stuck for an hour when they forget it. Then use the portal's OAuth2 URL generator to create an invite link with the bot scope, open that link, and add the bot to your server. It will show up offline for now - that is expected, because the code that brings it to life does not exist yet.
Step 2: Point Claude Code at an Empty Folder
Now switch to Claude Code. Open your empty project folder and start with a short brief so Claude knows what you are building before it writes anything. This is the highest-value thirty seconds of the whole project. Ask Claude to create a CLAUDE.md file that says: this is a Discord bot, it should be written in a beginner-friendly way, and here is what I want it to do first.
Keeping that brief in a CLAUDE.md file means Claude reads it on every turn and stops drifting. You will not have to re-explain the project each time you come back to it. If you have never used a project brief before, it is the same habit that makes every other Claude Code build go smoother, and it matters even more when the project has moving parts like a bot does.
Step 3: The First Prompt - Get It Online
Do not try to build the whole bot in one prompt. The goal of your first prompt is tiny and specific: get the bot to log in and come online in your server. Ask Claude something like "Set up a minimal Discord bot in this folder that logs in with my token and prints a message in the console when it is online." Claude will write the code and tell you how to add your token safely.
Run it, and watch your server. The moment that offline bot flips to online, you have crossed the hardest gap in the project. Everything after this is adding one small ability at a time. If it does not connect, copy the exact error message and paste it straight back to Claude - error messages are the most precise instructions you will ever get, and Claude is very good at reading them.
Step 4: Add Your First Command
Now give the bot something to do. Start with the classic: a command that replies when someone types it. Ask Claude to "add a slash command called ping that replies with pong." Run it again, type the command in your server, and watch the bot answer. It feels small, but you just wired a full round trip - a person types, the bot hears it, the bot responds.
That round trip is the whole pattern of a Discord bot. Every feature you will ever add is a variation of it: something happens in the server, your bot notices, your bot does something back. Once you have seen it work once, you know how to add anything. Add commands one at a time, test each one, and never move on until the current one works.
Step 5: Make It Do Something Actually Useful
A ping command proves the wiring. Now build the reason you wanted a bot in the first place. This is where Claude Code earns its keep, because you can describe a genuinely useful job in one sentence and let it build the logic. Pick one real job and ask for it plainly.
- A welcome message that greets every new member who joins your server.
- A command that posts a daily prompt or question to keep a community active.
- A moderation helper that flags messages containing words you choose.
- A command that fetches something useful, like the weather or a random resource, and posts it.
For anything that reaches outside Discord - pulling live data, posting to another service, checking a database - the next step up is connecting your bot to those tools through MCP servers. That is how a simple bot turns into something that runs real chunks of a workflow. Start simple, get one useful command working, and grow from there.
Step 6: Deploy It So It Runs While You Sleep
Here is the catch nobody tells beginners: your bot only runs while the program is running. Close your laptop and the bot goes offline. To keep it live around the clock, it needs to run on an always-on host instead of your machine. The good news is you can do this for free to start, and Claude Code will walk you through it.
Ask Claude to help you deploy the bot to a free always-on host - there are several beginner-friendly ones that keep a small bot running at no cost. Claude will tell you what to set up, where to paste your token as a secure environment variable, and how to push the code. Once it is deployed, your bot stays online whether your laptop is open or not. That is the moment it stops being a project and becomes a real thing running in the world.
Where to Take It Next
You now have the full loop: a bot registered on Discord, built command by command with Claude Code, and deployed so it runs on its own. That is more than most people ever ship. The skill you just picked up - describe a small slice, build it, test it, repeat - is the exact same skill behind every other project in this club, from Telegram bots to full agents.
So keep pulling the thread. Add one more command this week. Connect it to a tool through an MCP server. Turn it into something your community actually relies on. When you are ready for the next build, our walkthrough on building a Telegram bot with Claude Code follows the same shape, and the 6,800+ members inside the Claude Code Club are shipping bots like this every day. Pick the next small slice and keep going.
Frequently asked questions
Can I build a Discord bot with Claude Code if I have never coded before?
Yes. Claude Code writes the code for you - your job is to describe what the bot should do in plain English and handle the setup on Discord's side. The walkthrough above takes a complete beginner from an empty folder to a live bot without assuming any prior coding experience.
Is building a Discord bot free?
The build is free. Discord's Developer Portal is free, Claude Code writes the code, and there are free always-on hosts that will keep a small bot running at no cost. You can go from nothing to a deployed, live bot without spending anything to start.
Why is my Discord bot showing as offline?
A Discord bot is only online while its code is actually running. If you added the bot to your server but have not run the login code yet, or you closed the program, it will show offline. Once you run the code - or deploy it to an always-on host - it comes online and stays there.
Where do I keep the bot token safe?
Never put the token directly in your code or in anything you share. Ask Claude Code to store it in a separate environment file locally, and when you deploy, add it as a secret environment variable in your host's settings. If the token ever leaks, reset it in the Discord Developer Portal right away.
What can a Discord bot actually do once it is built?
Anything that follows the pattern of noticing something in the server and responding: welcoming new members, posting daily prompts, moderating messages, or fetching live data. When you connect it to outside tools through MCP servers, it can run real pieces of a workflow, not just reply to commands.
Last reviewed by David Iya on July 7, 2026


