BotDrop โ€บ Guides โ€บ How to Share a Self-Hosted Discord Bot on GitHub (Free)

How to Share a Self-Hosted Discord Bot on GitHub (Free)

By BotDrop ยท Updated October 27, 2026 ยท Free guide, no purchase needed

You built a Discord bot for your own server and now you'd like to let other people use it. You don't need a website or a store. A free GitHub repository is enough, and for a self-hosted bot it's where most people will look first. This guide covers what to do before you publish so strangers can set it up without messaging you.

Why GitHub is the right place

A self-hosted bot means every user runs the code on their own computer with their own bot token. That makes a code host a better fit than an app store or a bot list. GitHub gives you free public repositories, a place for a README, downloadable releases, issue tracking if you want it, and search. People who look for a self-hosted bot already know to look there.

It also takes the pressure off. You aren't running a service, so you don't have to keep a server up for anyone. You publish the code, explain how to run it, and users take it from there.

Step 1: Pick a license

This is the step people skip. When a public repository has no license, the default is that you keep all rights. GitHub's terms let others view and fork a public repo, but nobody is clearly allowed to copy, change or share your code beyond that. If you want people to run your bot, add a license.

If you don't care about money and just want it used, the MIT license is the usual choice. It's short and lets anyone use, change and share the code, as long as they keep your copyright notice. On GitHub you can add it from the Add file menu: create a file named LICENSE and pick a template. (We aren't lawyers; read the text and pick what fits you. choosealicense.com compares the common ones.)

Step 2: Move local settings into a .env file

If your code has things like http://localhost:5000, a folder on your own drive, or a channel ID for your server written straight into it, move those out. Anyone else who downloads the bot will have a different setup. Put each value in a .env file, and publish a .env.example with placeholder values so people know what to fill in.

# .env.example  (copy to .env and fill in your own values)
DISCORD_TOKEN=paste-your-bot-token-here
WEB_HOST=127.0.0.1
WEB_PORT=8080

Then read the values in Python with the python-dotenv package (pip install python-dotenv). os.getenv takes a default, so the bot still works if someone leaves a setting out:

import os
from dotenv import load_dotenv

load_dotenv()  # loads .env from the current folder, if it exists

TOKEN = os.getenv("DISCORD_TOKEN")
WEB_HOST = os.getenv("WEB_HOST", "127.0.0.1")
WEB_PORT = int(os.getenv("WEB_PORT", "8080"))  # env values are always text

if not TOKEN:
    raise SystemExit("DISCORD_TOKEN is missing. Copy .env.example to .env and fill it in.")

Two small things that trip people up: environment values are always strings, so convert ports to numbers; and on Windows, Notepad may save the file as .env.txt, which the bot won't find. Turn on "File name extensions" in File Explorer to check.

Step 3: Keep your bot token out of the repo

Your bot token is the bot's password. Anyone who has it can control your bot in every server it's in. Do this before your first push:

  1. Create a .gitignore file that lists .env (and usually __pycache__/ and .venv/).
  2. Run git status and confirm .env isn't listed as a file to commit.
  3. Search your code for any token you pasted in while testing.
.env
__pycache__/
.venv/

If the token was ever committed, even once, treat it as leaked. Adding a file to .gitignore doesn't remove it from commits you already made, and your Git history is public along with the code. If .env was already tracked, stop tracking it with git rm --cached .env. You can also check whether it's in old commits with git log --all --oneline -- .env.

The fix that matters is to reset the token: open the Discord Developer Portal, choose your application, open the Bot page and click Reset Token. The old token stops working, and you put the new one in your local .env. GitHub also scans pushes for Discord tokens and Discord may reset a leaked one for you, but don't count on it. GitHub's own advice is that once a secret is revoked, rewriting history may not even be necessary. See our token safety section for more.

Step 4: Add a requirements.txt

This lets people install everything with one command: pip install -r requirements.txt. Be careful with pip freeze. It lists every package in your Python environment, including ones your bot never uses, with exact versions that may not install on someone else's system. If you use it, run it inside a fresh virtual environment, or just write the file by hand with your direct dependencies and loose version limits:

discord.py>=2.3,<3
python-dotenv>=1.0,<2

Also note which Python version you tested on in the README.

Step 5: Write a five-step README

The README is the page people see first. It doesn't have to be fancy. Five steps and one screenshot of the bot working are enough. Here's a template to copy:

# My Bot

One sentence on what it does. [screenshot here]

## Setup
1. Install Python 3.10 or newer from python.org.
2. Download this repo (Code, then Download ZIP) and open a terminal in the folder.
3. Run: pip install -r requirements.txt
4. Create a bot at discord.com/developers/applications, copy its token,
   then copy .env.example to .env and paste the token in.
5. Run: python bot.py

## Settings
List each .env value and what it does.

## License
MIT

Add the invite step (the bot's OAuth2 link and the permissions it needs) if your bot needs one, and say plainly if it only runs while your PC is on.

Step 6: Publish a release with a zip

Not everyone uses Git. A release gives them a clear download. On your repo page, open Releases, click Create a new release, choose a new tag such as v1.0.0, add a title and a few lines of notes, and publish. GitHub automatically adds a zip and a tarball of your code at that tag. Future versions get their own tag and notes, so people can see what changed.

Step 7: Add topics so people can find it

On the repo's main page, click the gear next to About, add a short description, and add topics. Good ones for this kind of project are discord-bot, self-hosted and python, plus one or two for what it does. Topics use lowercase letters, numbers and hyphens, and you can add up to 20.

Optional: add a Dockerfile

You don't need one. Some people like Docker because it avoids Python version problems, so it's a nice extra if you already know it. A small one looks like this:

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "bot.py"]

Add a .dockerignore that lists .env so your token isn't copied into the image, and run it with docker run --env-file .env my-bot. If your bot starts a local web server, it must listen on 0.0.0.0 inside the container and you need to publish the port (-p 8080:8080), or the page won't open from your browser.

Running it: no server required

Tell users the truth about hosting: a self-hosted bot only runs while its program runs. On a home PC that's free, and it can run around the clock if the PC stays on and awake. Renting a small host for roughly $5–$8 a month is an option for people who want the bot up while their PC is off, not a requirement. Our guide on hosting a Discord bot on your PC for free is a good one to link from your README.

Examples of this layout

If you'd like to see finished repos, BotDrop publishes two free MIT-licensed tools on GitHub: Free Games Notifier Lite and Review Pulse for Steam. Both have a LICENSE, a README, a .gitignore, topics and a tagged release. Review Pulse also shows the settings pattern from Step 2, with a .env.example, and has a Dockerfile. Feel free to look at how they're organized.

Before you click public

  • A LICENSE file is in the repo.
  • No token, webhook URL or personal path appears in the code or history.
  • .env is ignored and .env.example is included.
  • requirements.txt installs cleanly in a fresh virtual environment.
  • The README steps work when you follow them on a clean folder.

That last check is the best one. Download your own zip into a new folder and follow your README exactly. Wherever you get stuck, other people will too.

Sources

Checked against these pages on October 27, 2026. Menus in GitHub and Discord move from time to time; if a button has a slightly different name, look for it nearby.

📬 Free games & bot updates by email

About one email a week: which games are free to keep right now, plus new or updated BotDrop bots. No spam; unsubscribe anytime.

You’ll get a confirmation email first. Privacy note

More free guides