Free hosting
Minecraft JavaMinecraft BedrockPaperMCFabricForgeGeyserMCTerrariaFactorioHytaleDiscord botsRLCraftCobblemonBetter MCCreateMinecraft IndiaAll modpacks
Go premium

No hibernation, no timers, 5 GHz CPUs and up to 32 GB RAM.

From €1.99/month →
Tools & help
RAM calculatorMOTD generatorServer status checkerserver.properties generatorColor codesServer icon makerDiscord permissionsAll free toolsGuidesDiscord community
Language
EnglishNederlandsEspañolFrançaisDeutschItalianoPortuguêsLatviešuPolskiSuomiNorskRomânăPortuguês (BR)Türkçeहिन्दीBahasa IndonesiaالعربيةTiếng Việt
Start free
Discord · Coding Guide

How to Make a Discord Bot and Host It Free 24/7 (Python & Node.js)

Discord bots can automate moderation, play music, track server stats, run games, and much more. The best part? Making a Discord bot is easier than most people think — and hosting it 24/7 for free is simple with FreeGameHost.

FreeGameHost logo FreeGameHost Guides Updated 11 min read
How to Make & Host a Discord Bot Free (2026)

Inviting your bot? Build the invite link with the right permissions in the Discord permissions calculator.

Ready to deploy? Step-by-step: host a discord.py bot or host a discord.js bot.

Discord bots can automate moderation, play music, track server stats, run games, and much more. The best part? Making a Discord bot is easier than most people think — and hosting it 24/7 for free is simple with FreeGameHost.

This guide covers everything from creating your Discord application to writing your first bot commands in both Python and Node.js, all the way to hosting your bot free 24/7 so it stays online even when your computer is off.

Quick answer

  1. Create an application in the Discord Developer Portal, enable Message Content Intents, and copy your bot token.
  2. Write your bot logic using discord.py (Python) or discord.js (Node.js) with structured slash command handlers.
  3. Deploy to a 24/7 cloud container host with automated uptime monitoring instead of running on your home PC.

Step 1 — Create a Discord application#

Before you write any code, you need to register your bot with Discord.

1.1
Go to the Discord Developer Portal

Visit discord.com/developers/applications and log in with your Discord account.

1.2
Create a new application

Click New Application, give it a name (this will be your bot's name), and click Create.

1.3
Add a Bot

In the left sidebar, click Bot, then click Add Bot. Confirm the action. You can optionally set an avatar for your bot here.

1.4
Copy your bot token

Click Reset Token and copy the token shown. This is your bot's password — keep it secret and never share it publicly.

1.5
Enable Privileged Intents

Scroll down on the Bot page and enable Server Members Intent and Message Content Intent. These are required for most bots to read messages and user data.

1.6
Invite the bot to your server

Go to OAuth2 → URL Generator. Select bot and applications.commands as scopes. Select the permissions your bot needs (Administrator for full access). Copy the generated URL and open it to add your bot to a server you manage.

Important: Never share your bot token. If it gets leaked, reset it immediately in the Developer Portal. Anyone with your token has full control of your bot.

Step 2a — Write a Discord bot in Python#

Python is the most beginner-friendly option for Discord bots. We'll use discord.py, the most popular Python Discord library.

Install discord.py#

If you're testing locally first, open a terminal and run:

pip install discord.py

Basic bot example (Python)#

Create a file called bot.py and paste this code:

Python
import discord
from discord.ext import commands

# Replace with your actual bot token
TOKEN = 'YOUR_BOT_TOKEN_HERE'

intents = discord.Intents.default()
intents.message_content = True
intents.members = True

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
    print(f'Bot is online as {bot.user}')

@bot.command()
async def hello(ctx):
    await ctx.send(f'Hello, {ctx.author.mention}! 👋')

@bot.command()
async def ping(ctx):
    latency = round(bot.latency * 1000)
    await ctx.send(f'Pong! Latency: {latency}ms')

@bot.command()
async def serverinfo(ctx):
    guild = ctx.guild
    await ctx.send(
        f'Server: {guild.name}\n'
        f'Members: {guild.member_count}\n'
        f'Created: {guild.created_at.strftime("%Y-%m-%d")}'
    )

bot.run(TOKEN)

This bot responds to three commands: !hello, !ping, and !serverinfo. To test locally, run python bot.py in your terminal.

Discord now recommends slash commands over prefix commands. Here's how to add them:

import discord
from discord import app_commands

TOKEN = 'YOUR_BOT_TOKEN_HERE'

intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)

@tree.command(name='ping', description='Check bot latency')
async def ping(interaction: discord.Interaction):
    latency = round(client.latency * 1000)
    await interaction.response.send_message(f'Pong! {latency}ms')

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

client.run(TOKEN)

Step 2b — Write a Discord bot in Node.js#

If you prefer JavaScript, discord.js is the most popular and well-documented option.

Set up your project#

mkdir my-discord-bot
cd my-discord-bot
npm init -y
npm install discord.js

Basic bot example (Node.js)#

Create a file called index.js:

JavaScript
const { Client, GatewayIntentBits } = require('discord.js');

const TOKEN = 'YOUR_BOT_TOKEN_HERE';

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

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

client.on('messageCreate', async (message) => {
  if (message.author.bot) return;

  if (message.content === '!hello') {
    await message.reply(`Hello, ${message.author}!`);
  }

  if (message.content === '!ping') {
    const latency = Math.round(client.ws.ping);
    await message.reply(`Pong! Latency: ${latency}ms`);
  }

  if (message.content === '!serverinfo') {
    const guild = message.guild;
    await message.reply(
      `Server: ${guild.name}\nMembers: ${guild.memberCount}`
    );
  }
});

client.login(TOKEN);

Run it locally with node index.js to test.

Tip: Store your bot token in an environment variable rather than hardcoding it. Create a .env file with TOKEN=your_token_here and use the dotenv package to load it. This prevents accidentally committing your token to GitHub.

Step 3 — Host your Discord bot free 24/7#

Once your bot works locally, you need to host it so it stays online 24/7 — even when your computer is off. FreeGameHost offers free Discord bot hosting for both Python and Node.js bots.

3.1
Create a free account

Sign up at panel.freegamehost.xyz. No credit card required.

3.2
Create a Discord bot server

Click Create Server and select Discord Bot as the server type. Choose Python or Node.js to match your bot's language.

3.3
Upload your bot files

Use the File Manager in your control panel to upload your bot files (bot.py or index.js, plus any other files your bot needs).

3.4
Install dependencies

Open the Console tab in your control panel and run pip install discord.py (Python) or npm install (Node.js) to install your bot's dependencies.

3.5
Set your startup command and start

Set the bot file (bot.py or index.js) on the Startup page, then click Start. Your bot comes online and keeps running 24/7 while your renewal timer lasts (each Renew adds 12 hours, up to 48 hours stored).

Useful bot commands to add next#

Once your basic bot is running, here are some popular commands to add:

  • Moderation: !kick, !ban, !mute, !clear (delete messages)
  • Fun: !roll (dice roller), !8ball (magic 8 ball), !coinflip
  • Info: !userinfo, !membercount, !botinfo
  • Welcome messages: Automatically greet new members when they join
  • Auto-roles: Assign roles to new members automatically
  • Reaction roles: Let users react to a message to get a role
  • Logging: Log deleted messages, user joins/leaves to a channel
Free Discord Bot Hosting Python and Node.js 24/7 bot hosting with web console.
Host Discord bot

Related: Free Discord Bot Hosting  •  Free Minecraft Server Hosting

Frequently asked questions#

How do I make a Discord bot for free?

Create a Discord application at discord.com/developers, write bot code in Python or Node.js, then host it for free on FreeGameHost with 256MB RAM and 24/7 uptime.

Can I host a Discord bot for free 24/7?

Yes. FreeGameHost offers free Discord bot hosting with 24/7 availability, Python and Node.js support, and no credit card required.

Do I need to know how to code to make a Discord bot?

Some basic programming knowledge helps, but Python is beginner-friendly and there are many tutorials available. If you want a bot without coding, consider using a no-code bot like MEE6 or Carl-bot instead.

Is Python or Node.js better for Discord bots?

Both work great. Python (discord.py) is better for beginners and those with data science or scripting backgrounds. Node.js (discord.js) is better if you already know JavaScript or plan to build more complex bots. Both are fully supported on FreeGameHost.

How do I keep my Discord bot online 24/7 for free?

Host it on FreeGameHost. You get 256MB RAM and 25% CPU dedicated to your bot, running 24/7 at no cost. Upload your code, install dependencies, and start the bot. It stays running even when your computer is off.

Can my bot be in multiple servers?

Yes. A single Discord bot can be in unlimited servers. Just generate a new invite link for each server you want to add it to.

How do I add a database to my Discord bot?

SQLite works great for small bots and requires no setup. For larger bots, consider using a free tier from PlanetScale or Supabase (PostgreSQL). Connect to your database from your bot code using a library like aiosqlite (Python) or better-sqlite3 (Node.js).