Hosting a Discord bot
Drop your bot's code, paste its token, and Lodebit keeps it online: it installs the dependencies, starts the bot, restarts it if it crashes and shows you its logs live.
Start from a template
Both starters have one slash command, /ping, and read the token from DISCORD_TOKEN.
Deploy in five steps
- In the Discord Developer Portal, create an application, open Bot, and reset and copy the token.
- In Lodebit, open Bots → New bot and drop your bot's folder or .zip.
- Check the runtime and start command it detected. Change them if they're wrong.
- On the Secrets step, paste the token as
DISCORD_TOKEN. Add any other keys your bot needs. - Launch. When the logs say it has logged in, invite it: Developer Portal, OAuth2, URL Generator, tick
botandapplications.commands, and open the link.
How Lodebit runs your bot
Runtime and start command
- Node.js if there's a
package.jsonat the top. It runsnpm startif there's a start script, otherwisemain, otherwise the first ofindex.js,bot.js,main.jsorsrc/index.js. - Python if there's a
requirements.txtorpyproject.toml. It runs the first ofmain.py,bot.py,app.py,src/main.pyorsrc/bot.py. - The start command runs directly, not through a shell, so it can't use
;,&&, pipes or$VARIABLES. Letters, numbers, spaces and. _ / @ : = + -are allowed. - You can change the runtime and start command in the bot's settings. The change applies from the next deploy.
Dependencies
- Node.js:
npm ciwhen there's a lockfile,npm installotherwise. Ifpackage.jsonhas abuildscript (TypeScript, bundlers), it runs that, then removes dev dependencies. - Python:
pip install -r requirements.txt, orpip install .for apyproject.toml. - Dependencies always install fresh, so a
node_modules,.venvor.gitfolder in your upload is skipped. Packages come from the npm and PyPI registries only; packages that compile native code may not build.
Secrets
- Secrets reach your bot as environment variables:
process.env.DISCORD_TOKENin Node.js,os.environ["DISCORD_TOKEN"]in Python. - They're encrypted in your browser before they're sent. Only the server that runs your bot can decrypt them, and nobody, including you, can read a value back. The dashboard shows a masked preview like
MTIz…xY9. - If your bot prints a secret, the logs show
[redacted]instead. - After adding or changing a secret, restart the bot so it picks up the new value.
.envfiles are removed from uploads, so tokens can't end up inside your bot's files. Use the Secrets page instead.- Names use capitals, digits and underscores. These are set by Lodebit and can't be used:
HOME,LD_PRELOAD,LODEBIT_BOT,NODE_OPTIONS,ORBYT_BOT,PATH,PYTHONPATH,USER.
Limits
| Bots per account | 3, shared with site backends |
|---|---|
| Memory | 256 MB. A bot that goes over is stopped and restarted, and the logs say so. |
| CPU | A quarter of a core |
| Processes and threads | 128 |
| Files | Your code is read-only. Write lasting files to /data (also in LODEBIT_DATA_DIR): 100 MB, kept across restarts and deploys. Over the limit it turns read-only until you reset it on the bot's page. It isn't backed up yet. /tmp (64 MB) is emptied on every restart. |
| Network | Outgoing connections only. Bots can't receive incoming connections or run a public web server. |
| Upload size | 50 MB zipped |
Restarts, crashes and logs
- If your bot exits, it's restarted after a short wait that grows with each crash (2 seconds, then 4, 8, up to a minute).
- If it crashes 5 times within 10 minutes, it's stopped so it doesn't loop forever. Fix the error in the logs and press Start.
- Before a stop, restart or redeploy, your bot gets
SIGTERMand 10 seconds to log out. The starters handle this. - Logs show everything your bot prints to standard output and standard error, live. The newest 5,000 lines are kept for 7 days.
- A new deploy builds while the current version keeps running, then the bot switches over. If the build fails, nothing changes.
Troubleshooting
"An invalid token was provided" or "401 Unauthorized"
The first is discord.js, the second discord.py. The value in DISCORD_TOKEN isn't a bot token. Copy it from the Bot page in the Developer Portal, not the client secret or application ID, then replace the secret and restart.
"Used disallowed intents"
Your bot asks for a privileged intent (message content, members or presence). Turn it on under Bot → Privileged Gateway Intents in the Developer Portal, or remove it from your code.
Slash commands don't appear
Global commands can take a few minutes to show up after the first sync. Check the bot was invited with the applications.commands scope.
"ran out of memory"
The bot used more than 256 MB. Look for caches that grow forever, like storing every message.
The build fails
The deploy log shows the install output. Make sure the lockfile matches package.json, and that every package is on npm or PyPI.
Rules
Bots must follow Discord's Terms of Service and Developer Policy, and our Terms of Service. No self-bots, spam, raids or scraping users. Breaking the rules gets the bot, and possibly the account, suspended.