A collection of utilities and extensions for discord.py bots.
- Python 3.13+
- discord.py 2.4+
You can run your own bot without writing any code.
You will need the following:
- Your own Discord Application with a bot token.
- A configuration file for the bot.
- A Python 3.13+ environment.
- It is recommended to use a virtual environment for this.
- You can use pyenv to build and run Python 3.13.
- Run
pip install commanderbot
to install the bot core package.
The first thing you should do is check the CLI help menu:
python -m commanderbot --help
There are several ways to provide a bot token:
- (Recommended) As the
BOT_TOKEN
environment variable:BOT_TOKEN=put_your_bot_token_here
- Supports
.env
files: use.env
in the working directory or provide the--envfile
option
- Supports
- As a CLI option:
--token put_your_bot_token_here
- As a standalone file:
--tokenfile path_to_file_with_bot_token
- Manually, when prompted during start-up
Here's an example that provides the bot token as an argument:
python -m commanderbot bot.json --token put_your_bot_token_here
The current set of configuration options is limited. The following is an example configuration that sets the command prefix, enabled privileged intents, and loads the sudo
, status
and faq
extensions.
The
sudo
extension is essential to managing the bot. It can do things like syncing commands, setting the bot's profile picture, or even exporting the config.
An extension prefixed with
$
means the extension is required and cannot be managed while the bot is running. If the extension's config uses the object syntax, you can make the extension required by adding"required": true
.
Note that with this configuration, the
faq
extension will require read-write access tofaq.json
in the working directory.
{
"command_prefix": ".",
"privileged_intents": {
"message_content": true,
"members": true
},
"extensions": [
"$commanderbot.ext.sudo",
"commanderbot.ext.status",
{
"name": "commanderbot.ext.faq",
"options": {
"database": "faq.json"
}
}
]
}