Your bot’s code is already on GitHub. Zipping it and uploading it by hand every time you change a line makes no sense. This guide shows how to deploy a Discord bot from GitHub straight from the repository, then sets it up so updating it is a git push and a restart.
It works for any language the platform runs: discord.js, discord.py, JDA, a Telegram bot, an API.
Before you start: a deploy-ready repository
Check three things in your repository:
- No token in the code. Read it from an environment variable:
process.env.DISCORD_TOKENin Node.js,os.environ["DISCORD_TOKEN"]in Python. A token pushed to a public repository is detected and reset by Discord within minutes, which ends in a TokenInvalid error. - Dependencies are declared, not committed.
package.jsonfor Node.js,requirements.txtfor Python.node_modulesand virtualenvs stay out of git. - A
.gitignorethat keeps secrets and build junk home:
node_modules/
.env
__pycache__/
*.db The deployment installs the dependencies itself on every start: npm install when it finds a package.json, pip install -r requirements.txt for Python.
Step 1: deploy the bot from GitHub
Sign in to Bot-Hosting.net with Discord and start a new deployment:
- What are you deploying? Application, then your runtime (Node.js, Python, Java, Go…).
- Source: choose GitHub.
- Public repository: paste
https://github.com/you/your-botin the repository URL field. No GitHub account to connect. - Private repository: click Connect GitHub (or Authorize on GitHub if GitHub is connected but cannot list private repositories yet), then Choose a repository.
- Public repository: paste
- Pick the Branch, usually
main. - Leave Pull automatically at every restart on. More on it below.
- Click Launch deployment.
The entry file defaults to index.js for Node.js and main.py for Python. If your bot starts from another file, change Entry file in the Startup tab.
The repository is cloned onto the deployment, and the files appear in the Files tab.
Step 2: add the token
Open the Environment tab, click Add variable, enter DISCORD_TOKEN with your bot token as the value, and tick Secret. Saving restarts the deployment.
The Console shows the clone, the dependency install, then your bot’s own startup line. That is it: about two minutes from repository to online bot.
Step 3: update with git push
With auto-pull on, the deployment is a git checkout of your branch. Every restart fetches the latest commit before starting the bot:
git commit -am "Add /weather command"
git push Then click Restart. The deployment’s GitHub tab (under More) also has Pull now, which fetches the new commit and restarts the bot on it, and shows whether the deployment is “Up to date” or a number of commits behind.
What auto-pull keeps and overwrites
| File | On pull |
|---|---|
| Files tracked by the repository | Updated to the branch |
.env, node_modules, databases, uploads, anything untracked | Kept |
So a data.db or data/users.json written by the bot survives every update, as long as it is not committed. Do not edit tracked files on the server: the next pull overwrites them. Change them in the repository instead.
Auto-pull adds a few seconds to each restart. You can switch it off in the GitHub tab with Auto-pull at restart, and pull by hand when you choose.
Add a “Deploy” button to your README
If your bot is open source, let others run their own copy in one click. A deploy link pre-fills the whole form:
https://bot-hosting.net/deploy?source=github&url=https://github.com/you/your-bot Add &branch=dev to pick a branch, &name=my-bot to suggest a name. As a badge in your README:
[](https://bot-hosting.net/deploy?source=github&url=https://github.com/you/your-bot) Going further, publish it as a template: once reviewed, it gets its own page in the template catalogue, with the environment variables it needs listed, so people can find your bot through search.
Git or the CLI?
Two ways to ship changes, pick one per deployment:
- GitHub with auto-pull when the repository is the source of truth: you push, you restart, collaborators do the same.
- The Bot-Hosting CLI when you iterate fast from your editor:
bh deploy --watchpushes every save, no commit needed.
Mixing both on the same deployment works, but the next pull overwrites tracked files the CLI changed.
Troubleshooting
- Clone failed: the repository is private and GitHub is not connected, or the URL has a typo. The Console says so in plain English.
Cannot find module/No module named: a dependency is missing frompackage.jsonorrequirements.txt. Add it, push, restart.- The bot starts the wrong file: change the entry file in the Startup tab.
- Still stuck? Click Ask AI: it reads the logs and your repository’s files and points to the line to change.
Try it on a template
The fastest way to see the flow is to deploy a bot that is already set up. Discord Tickets is the most popular open-source ticket bot, deployed from its GitHub repository with a web panel on its own HTTPS address.