How to Create a Discord Bot for Free on Replit in 2026

So you want to build a Discord bot, but you don't want to spend a dime on hosting or complicated server setups? You're in the right place. In 2026, creating a functional, always-on bot is easier than ever — especially if you use Replit as your free development and hosting platform. This guide walks you through every single step, from generating your bot token to adding real moderation features. No fluff, just action.

By the end of this tutorial, you'll have your own custom Discord bot running 24/7 for free. And if coding isn't your thing? I'll also show you a smarter shortcut using Murffy, a ready-made moderation bot that does the heavy lifting for you.

What You’ll Need Before You Start

Before we jump into code, let's make sure you have the basics covered. Honestly, most beginners skip this step and then wonder why nothing works. Don't be that person.

Prerequisites: Discord Account, Replit Account, Basic Coding Knowledge

  • A Discord account with a server where you have "Manage Server" permissions. If you don't have a server, create one — it's free and takes 30 seconds.
  • A free Replit account at replit.com. No credit card required. Seriously, it's that simple.
  • Basic familiarity with JavaScript/Node.js — or at least a willingness to follow along. You don't need to be a pro; copy-paste with understanding works fine.

Got all that? Good. Let's build something.

Step 1: Create a Discord Application and Bot Token

Every bot needs a digital identity. Think of this as your bot's passport to the Discord world.

Registering Your Bot on the Discord Developer Portal

  1. Head over to the Discord Developer Portal (discord.com/developers/applications).
  2. Click "New Application", give it a name (something like "My Free Bot" or "ModBot 2026"), and hit create.
  3. In the left sidebar, click the "Bot" tab, then click "Add Bot". Confirm the popup.
  4. Now you'll see a token — a long string of characters. Copy it immediately and keep it secret. If you lose it, you can regenerate it, but treat this like a password.
  5. Under the "Privileged Gateway Intents" section, enable "Server Members Intent" and "Message Content Intent". Without these, your bot won't see messages or member events.

One quick warning: never share your bot token publicly. If someone gets it, they can control your bot. Store it safely.

Step 2: Set Up Your Bot on Replit

Now we bring your bot to life in a cloud environment. Replit is perfect for this because it handles all the server stuff for you.

Cloning a Starter Template and Configuring Environment Variables

  1. Log into Replit and click "Create Repl". Choose the Node.js template.
  2. If you want to skip typing everything from scratch, clone a starter repo. In the Shell tab (bottom panel), run:
    git clone https://github.com/your-starter-repo-url . (Replace with a real starter URL or just use the blank template.)
  3. Now for security: click the padlock icon (Secrets) in the Replit sidebar. Add a new secret with the key DISCORD_TOKEN and paste your bot token as the value. This keeps your token out of your code.
  4. In the Shell, run npm install discord.js to install the Discord.js library. If you cloned a starter, it might already be in package.json — just run npm install.

Pro tip: never hardcode your token in the code. Using Replit Secrets means your bot stays secure even if you share your code publicly.

Step 3: Write the Basic Bot Code

This is where the magic happens. We'll write a minimal bot that responds to a simple command.

Coding a Simple Ping Command and Event Handlers

Open the index.js file (or create it) and paste the following code:

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

client.once("ready", () => {
  console.log(`Logged in as ${client.user.tag}! Bot is online.`);
});

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

client.login(process.env.DISCORD_TOKEN);

Let's break this down:

  • Line 1-2: We import Discord.js and create a client with the three intents we enabled earlier.
  • Lines 7-9: The ready event fires once when the bot starts. It logs a confirmation.
  • Lines 11-15: Every time someone sends a message, we check if it's "!ping". If yes, the bot replies "Pong!".
  • Line 17: This logs the bot in using the token stored in Replit Secrets.

Click "Run" in Replit. If everything's correct, you'll see "Logged in as YourBotName#1234! Bot is online." in the console. Now invite your bot to a server using the OAuth2 URL generator in the Developer Portal (select "bot" and "Send Messages" permissions).

Test it: type !ping in any channel your bot can see. It should reply "Pong!".

Step 4: Host Your Bot for Free (24/7 Uptime)

Your bot runs only while the Replit tab is open. That's not ideal. Here's how to keep it alive around the clock.

Using Replit’s Always-On Feature and Uptime Monitors

Replit offers an "Always-On" feature — but it's locked behind a paid subscription (Replit Core). For a free workaround, we use an external pinging service.

  1. After your bot is running, copy the URL of your Repl (it looks like https://your-repl-name.your-username.repl.co).
  2. Sign up for a free account at UptimeRobot (or a similar service).
  3. Create a new monitor, choose "HTTP(s)", paste your Repl URL, and set the check interval to 5 minutes.
  4. UptimeRobot will ping your bot every 5 minutes, preventing Replit from putting it to sleep.

Is this 100% reliable? Not quite. Free Replit instances still get occasional restarts. But for a small community bot, it works well enough. If you need rock-solid uptime, consider Fly.io or Railway — both have generous free tiers. But for a Discord bot development tutorial aimed at beginners, Replit + UptimeRobot is the easiest path.

Step 5: Add Moderation Features (Optional but Recommended)

A bot that only says "Pong!" is cute. A bot that keeps your server clean? That's valuable. You have two routes here: build your own or use a proven solution.

Extending Your Bot with Moderation Commands or Using Murffy

Option A: Code your own moderation commands.

Add commands like !kick, !ban, and !mute. Here's a quick example for !kick:

client.on("messageCreate", async message => {
  if (message.content.startsWith("!kick")) {
    if (!message.member.permissions.has("KickMembers")) {
      return message.reply("You don't have permission to kick members.");
    }
    const user = message.mentions.users.first();
    if (user) {
      const member = message.guild.members.cache.get(user.id);
      if (member) {
        await member.kick("Kicked by bot command");
        message.channel.send(`${user.tag} was kicked.`);
      }
    }
  }
});

This works, but it's basic. You'd need to add error handling, role checks, and audit logging yourself. That's a lot of work for a free bot.

Option B: Use Murffy for a hassle-free moderation bot setup.

If you'd rather skip the coding grind, head over to murffy.xyz. Murffy is a powerful, free Discord moderation bot that handles auto-moderation, logging, custom commands, anti-spam, and word filters right out of the box. You don't need to write a single line of code. Just invite it, configure it in a dashboard, and you're done. For community managers who want results fast, it's the best Discord bot hosting alternative to building from scratch.

Honestly, I'd recommend this route for most server owners. Building your own bot gives you full control, but Murffy saves you dozens of hours and includes features that would take weeks to code yourself.

Troubleshooting Common Issues

Things will break. Here's how to fix the most common problems.

Fixing Token Errors, Intents Problems, and Bot Not Responding

  • Bot won't come online: Double-check your token in Replit Secrets. Make sure the key is exactly DISCORD_TOKEN. Also verify that intents are enabled in the Developer Portal.
  • Commands don't work: Ensure your bot has the necessary permissions in your server — at minimum "Send Messages" and "Read Message History". You can adjust these in Server Settings > Roles.
  • "Process exited with code 0" error: This usually means your code crashed. Check for syntax errors in your index.js. A missing comma or bracket will kill the process. Also make sure client.login() is the last line.
  • Bot is online but doesn't respond to messages: Verify you enabled "Message Content Intent" in the Developer Portal. Without it, your bot can't read message content.

If you're stuck, check the Discord bot API documentation for detailed explanations of intents and permissions. It's your best friend.

What’s Next? Scaling and Improving Your Bot

Your bot works. You've mastered the basics of how to make a Discord bot. Now what?

Adding Slash Commands, Databases, and Premium Hosting

  • Slash commands: Modern Discord bots use slash commands (/ping instead of !ping). Discord.js v14+ supports them natively. It's a bit more code, but users love the clean interface.
  • Persistent data: Use Replit Database or MongoDB Atlas (free tier) to store user warnings, XP levels, or custom settings. This turns a toy bot into a real tool.
  • Better hosting: When your bot grows beyond a few servers, Replit's free tier will feel limiting. Consider migrating to a VPS (like a $5/month DigitalOcean droplet) or a dedicated bot hosting service. But for now, free works.

And if you ever feel overwhelmed by the complexity of building and maintaining a custom bot, remember: Murffy at murffy.xyz already does all this and more, for free. It's the shortcut that lets you focus on your community instead of your code.

Summary

Here's what you accomplished today:

  1. Created a Discord application and generated a bot token.
  2. Set up a Node.js bot on Replit with secure token storage.
  3. Wrote a basic ping-pong bot with event handlers.
  4. Kept the bot running 24/7 using UptimeRobot.
  5. Added moderation features — either by coding them yourself or using Murffy for a ready-made solution.
  6. Troubleshot common issues and learned where to go next.

You now have a fully functional Discord bot running for free. Whether you continue coding or switch to Murffy, your server is better off than when you started. Go make something awesome.

Najczesciej zadawane pytania

Do I need to pay anything to create a Discord bot on Replit in 2026?

No, you can create a Discord bot for free on Replit. The platform offers a free tier that allows you to code, host, and run your bot without any upfront costs, though you may need to upgrade for extended uptime or additional resources.

What programming language is commonly used to create a Discord bot on Replit?

Python is the most common language for creating Discord bots on Replit due to its simplicity and the popular `discord.py` library. However, you can also use JavaScript with `discord.js` or other languages supported by Replit.

How do I keep my Discord bot running 24/7 on Replit for free?

To keep your bot running 24/7, you can use a monitoring service like UptimeRobot to ping your Replit bot's URL periodically. Alternatively, you can upgrade to a Replit paid plan for always-on hosting, but the free tier with a ping service is a common workaround.

What is the first step to create a Discord bot on Replit?

The first step is to create a new Discord application on the Discord Developer Portal, then add a bot user to it and copy the bot token. After that, you write your bot code on Replit and use the token to connect your bot to Discord.

Can I host a Discord bot on Replit without coding experience?

Basic coding knowledge is required to create a Discord bot on Replit, but there are many beginner-friendly tutorials and templates available. You can start with simple commands and gradually learn more advanced features.