Skip to content
Tarisu Limited

Choosing between Node.js and Python for your bot

Updated: 29 October 202623 views

Discord bot hosting plans run your bot in a container on the game panel, under one of two runtimes: Node.js or Python. The runtime is chosen when the service is created.

Which one

This is decided by the code you already have, not by preference. Look at the bot's source:

  • A package.json, and imports of discord.js. That is Node.js.
  • A requirements.txt or .py files, and imports of discord or nextcord. That is Python.

If you are writing from scratch and genuinely have no preference, pick the language you already know. Both run a Discord bot perfectly well on these plans, and the library ecosystems for each are mature. Neither is faster in any way you will notice for a bot that spends most of its life waiting on the gateway.

What to upload

Use the file manager in the game panel, or upload a zip and extract it there.

  • Node.js: your source, package.json and package-lock.json. Do not upload node_modules: the dependencies are installed on the container. Make sure the start script in package.json points at the right file.
  • Python: your source and a requirements.txt listing the packages you import. Set the startup file to the one that actually starts the bot.

Keep the bot token out of the files you upload. Put it in an environment variable on the container and read it from there. A token committed to a repository or left in a source file is the most common way a bot gets taken over.

Resources

The plans differ in memory, CPU share and disk: 1 GB, 3 GB or 5 GB of memory, with a matching CPU allowance. A typical command bot runs comfortably in the smallest; music and anything that processes audio or images is what pushes memory up. Watch the usage in the panel for a day or two before deciding you need more.

Changing the runtime later

You can switch between the two runtimes from the service page in the client area. Be careful with it: changing the runtime rebuilds the container, and everything on it is deleted: your files, your settings and your logs. It cannot be recovered.

So decide before you upload, keep your source in version control, and if you do have to switch, take a backup and download it first.