Headless Mode
Every BotBox command can run without the interactive TUI. This makes BotBox usable from scripts, Makefiles, and CI pipelines.
Added in 2.6.0.
How BotBox Decides
A command runs headless when either of these is true:
- You pass
--headlessexplicitly - You pass any value flag, such as
--name,--commands,--yes, etc.
--headless is a persistent flag, so it is available on every command.
Headless runs also skip the automatic update check, so a slow or unreachable GitHub API never stalls a pipeline.
Creating a Project
botbox create and botbox init share the same flag set.
botbox create --name MyBot --description "A really cool bot" --author "John Doe" --token YOUR_TOKEN --guild GUILD_IDProject flags:
| Flag | Description |
|---|---|
--name | Bot name, can also be given as the first positional argument |
--description | Bot description |
--author | Bot author, falls back to user.default_user in the global config |
--prefix | Single non-alphanumeric command prefix, falls back to defaults.command_prefix, then ! |
--env | env or doppler, defaults to env |
--token | Bot token, used when --env env |
--guild | Guild ID, used when --env env |
--doppler-project | Doppler project name, required when --env doppler |
--doppler-env | Doppler environment name, used when --env doppler |
--license | mit, apache-2.0, gpl-3.0, bsd-3-clause, unlicense, or no-license |
--force | Overwrite existing files without prompting |
Keeping Your Token Out of Shell History
--token is read from the BOTBOX_TOKEN environment variable when the flag is omitted.
export BOTBOX_TOKEN=YOUR_TOKEN
botbox create --name MyBot --description "A really cool bot" --author "John Doe"--token on the command line writes your bot token into your shell history and into CI logs on some runners. Prefer BOTBOX_TOKEN.Doppler Projects
botbox create --name MyBot --description "A really cool bot" --author "John Doe" \
--env doppler --doppler-project my-project --doppler-env dev--doppler-project is required when --env doppler is set.
Initializing In Place
botbox init takes the same flags and writes into the current directory instead of a new one.
botbox init --name MyBot --description "A really cool bot" --author "John Doe"Adding a Cog
botbox add takes the cog name as a positional argument and the commands as JSON through --commands.
botbox add Greeter --commands '[
{
"Name": "greet",
"Scope": "guild",
"Type": "slash",
"Description": "Greets a user",
"Args": [
{ "Name": "user", "Type": "discord.Member", "Description": "The user to greet" }
],
"ReturnType": "None"
}
]'--commands also accepts a file path prefixed with @, or - to read from stdin.
botbox add Greeter --commands @commands.json
cat commands.json | botbox add Greeter --commands -To generate an empty cog with no commands, pass --headless on its own.
botbox add Greeter --headlessAdding a Modal Command
Modal commands take Fields instead of Args, and Type is modal.
botbox add Feedback --commands '[
{
"Name": "feedback",
"Scope": "guild",
"Type": "modal",
"Description": "Collects user feedback",
"Fields": [
{ "Name": "subject", "Label": "Subject", "Style": "short", "Required": true, "Placeholder": "Short summary" },
{ "Name": "details", "Label": "Details", "Style": "paragraph", "Required": false, "Placeholder": "" }
],
"ReturnType": "None"
}
]'Between one and five fields, Style is short or paragraph, and ReturnType is forced to None. See Modal Commands.
Removing a Cog
botbox remove Greeter --yes-y, --yes removes the cog without the TUI and without a confirmation prompt.
Reading Configuration
botbox config prints JSON or YAML instead of the TUI when you pass --format.
botbox config --format json
botbox config -g --format jsonbotbox config get prints only the value with --raw, which is what you want inside a shell substitution.
BOT_NAME=$(botbox config get bot.name --raw)
echo "Deploying $BOT_NAME"Syncing
botbox config sync --headlessThis prints a plain text report of what changed instead of rendering the TUI.
Full Example Script
#!/bin/bash
set -e
export BOTBOX_TOKEN="$DISCORD_TOKEN"
botbox create --name MyBot --description "Scaffolded in CI" --author "ci" --guild "$DISCORD_GUILD" --force
cd MyBot
botbox add Greeter --commands @../cogs/greeter.json
botbox config sync --headless
botbox config --format json