One plan can run several bots. Your main bot stays in the top folder, as it is now, and every other bot gets a folder of its own inside bots. They share the plan's memory and processor, so a handful of small bots fit on Flurry.
Add a bot
- In Files, create a folder called
botsin the top folder, then a folder inside it for the bot, for examplebots/tickets. Letters, numbers, dots, dashes and underscores only. - Upload that bot's files into its folder, with its
bot.pyorindex.jsat the top of the folder (not in another folder inside it). - In the same folder, create a file called
.envwith the bot's token:
Use a different bot's token from the one in Startup. Two bots logging in with one token keep knocking each other offline.BOT_TOKEN=the token of this bot - Press Restart. The console shows
[tickets]in front of everything that bot prints.
The top folder does not need a bot of its own. If it has none, only the bots in bots run.
Every bot on a server uses the language the server is set to (Startup > Docker Image): a Python server runs Python bots, a Node.js server JavaScript bots.
A bot's .env
Everything in a bot's .env reaches that bot as an environment variable, so os.environ["DB_HOST"] or process.env.DB_HOST work without loading the file yourself (loading it with dotenv as well does no harm). A few names also change how the bot is run, the same settings Startup has for the main bot:
BOT_TOKEN: the token.DISCORD_TOKENworks too, for bots that expect that name.BOT_FILE: what to start, if it is not found by itself. Same choices as Bot file.GIT_REPO,GIT_BRANCH,GIT_TOKEN: deploy this bot from its own repository into its folder.AUTO_UPDATE=0stops it pulling on every restart. See Git deploy.CRASH_WEBHOOK: a Discord webhook for this bot's crash alerts. Without one, the server's alert from Startup is used.ENABLED=false: leave this bot switched off. Renaming its folder to start with_does the same.
The Bot settings page in the panel checks each bot's token with Discord (its name, and which privileged intents are on), and edits these files as a form, one bot at a time, and can restart just that bot when you save; the others keep running. Tokens, passwords and keys are never shown there, only whether they are set, and typing a new value replaces one. When a bot's folder has a .env.example (or .env.sample, example.env), the page lists the settings it names that the .env does not have yet, with the comment written above each, so you can add them in one click. A changed setting reaches the bot the next time it starts (bots restart NAME, or after a crash); BOT_FILE, the Git settings and BEFORE_START need a full Restart of the server.
Packages
requirements.txt or package.json in a bot's folder install when they change, like the main bot's. Each Python bot gets a separate environment, so two bots can use different versions of the same package.
When a bot stops
The other bots keep running. The one that stopped is explained in the console and started again after 5 seconds, then after longer waits if it keeps stopping straight away. After 5 stops in a row, each within a minute of starting, it is left stopped until you fix it. Crash alerts name the bot.
The server itself stays online throughout, so Wings never marks it as crashed. The email we send when a bot has been down for hours is for servers running one bot.
Console commands
With bots in bots, the console understands:
bots: which bots are running, for how long, and how much memory each is using.bots restart tickets,bots stop tickets,bots start tickets: one bot, without touching the others.bots update tickets: pull that bot's newest commits from Git (and its packages, if they changed) and restart only it.@tickets some text: send a line to that bot's input. Anything else you type goes to the main bot.
The same buttons are on the Crashes page, under Right now: each bot with whether it is running, restarting or stopped, and Start, Stop, Restart and Update for that one bot. They type the command above for you, so the console shows what happens. Subusers need the console permission to use them.
Memory and limits
- Up to 10 bots in
bots, plus the main bot. - All of them share the plan's memory. Node.js and Java bots each get an equal part of the memory for their heap, so one leaking bot runs out of room before it can take the others down.
- The Crashes page shows each running bot's memory, so you can see which one is growing.
- If the server runs out of memory altogether, the plan is too small for the bots on it. How much RAM a bot needs.
Something here wrong or out of date? Tell us and it gets fixed.