-
Notifications
You must be signed in to change notification settings - Fork 1
Setup Guide
This guide will walk you through installing, configuring, and running JohnnyBot on your Discord server.
- Prerequisites
- Installation
- Discord Bot Token Registration
- Required Discord Permissions
- Configuration
- Running the Bot
- Troubleshooting
Before you begin, ensure you have:
- Python 3.11 or higher (tested on 3.11 and 3.12 in CI)
- Git for cloning the repository
- A Discord server where you have administrative permissions
git clone https://github.com/burbsec/johnnybot.git
cd johnnybotpip install -r requirements.txtNote: Consider using a virtual environment to avoid conflicts with other Python packages:
python -m venv johnnybot-env source johnnybot-env/bin/activate # On Windows: johnnybot-env\Scripts\activate pip install -r requirements.txt
Follow these steps to create a Discord bot and get your token:
- Go to the Discord Developer Portal
- Click "New Application"
- Give your application a name (e.g., "JohnnyBot")
- Click "Create"
- In your application, navigate to the "Bot" section in the left sidebar
- Click "Add Bot"
- Confirm by clicking "Yes, do it!"
- Under the "Token" section, click "Copy" to copy your bot token
- Keep this token secure - you'll need it to run the bot
- Navigate to the "OAuth2" section in the left sidebar
- Click on "URL Generator"
- In "Scopes", select "bot" and "applications.commands"
- In "Bot Permissions", select the permissions listed in the Required Discord Permissions section below
- Copy the generated URL and open it in your browser
- Select your Discord server and authorize the bot
JohnnyBot requires specific Discord permissions to function properly. When creating your bot application and generating an invite link, ensure these permissions are selected:
| Permission | Required For |
|---|---|
| Manage Server | Server management features |
| Manage Roles | Role permission cloning and voice channel safety features |
| Manage Channels | Channel permission cloning and management |
| Kick Members |
/kick command |
| Manage Nicknames | Voice channel safety (muting members) |
| Manage Events | Creating Discord events from calendar feeds |
| View Channels | Access and monitor channels |
| Moderate Members |
/timeout command |
| Permission | Required For |
|---|---|
| Send Messages | Bot responses and notifications |
| Manage Messages | Purge commands and protected channel enforcement |
| Read Message History | Message dump functionality and purge commands |
| Use Slash Commands | All slash command functionality |
| Embed Links | Rich embed messages (event notifications) |
| Attach Files | Log file attachments |
| Kick Members |
/kick, /kick_role, and the automatic DM kick (see below) |
| Manage Roles |
/server_restore, role management, permission cloning commands |
| Manage Channels |
/server_restore, permission cloning commands |
| Manage Emojis and Stickers |
/server_restore (recreating custom emoji) |
Note on the two different "permission" checks: the table above is what the bot's own role needs (set once, when you invite it). Separately, most commands check whether the person running the command has the Manage Messages permission (or Administrator for
/server_backup,/server_restore,/auto_backup) — see Commands Reference. There's no role name to configure for either check.
Anyone who sends the bot a direct message is kicked from every server they share with it, and the kick is posted to the moderators channel. This is always on and has no config toggle.
Exempt from the kick:
- Users with the Manage Messages permission
- Anyone the bot DMed in the last 24 hours, so replying to a
/message_dumparchive or/log_tailoutput is safe
Make sure your members know this before you invite the bot, and confirm the bot's role sits high enough in the hierarchy to kick the members you expect it to — a kick it cannot perform is logged as an error and reported, not silently ignored.
| Permission | Required For |
|---|---|
| Connect | Monitor voice channels for safety features |
| Mute Members | Voice channel chaperone functionality |
| Move Members | Voice channel management |
- The bot's own role does NOT need Administrator — grant it the specific permissions in the table above instead. (Separately, the user running
/server_backup,/server_restore, or/auto_backupdoes need Administrator — that's a command-access check, not a bot-invite permission.) - Ensure the bot's role is positioned high enough in the role hierarchy to manage the roles and channels it needs to work with
- For permission cloning commands, the bot cannot clone permissions to/from roles higher than its own highest role
Copy the example config and edit it for your server (config.py is gitignored, so your customizations won't conflict with git pull):
cp config_example.py config.pyThen modify the constants in config.py according to your server's setup:
# Required Configuration
PROTECTED_CHANNELS = {'announcements', 'rules'} # Read-only channels
MODERATORS_CHANNEL_NAME = 'moderators_only' # Channel for bot notificationsThere's no moderator role to name — command access and the exemptions above are based on the Discord Manage Messages / Administrator permissions directly, so a fresh server with no custom roles works out of the box as long as the members who should have mod access hold one of those permissions.
| Setting | Description | Example |
|---|---|---|
PROTECTED_CHANNELS |
Set of channels you wish to force to read-only when Discord requires them not to be | {'announcements', 'rules'} |
MODERATORS_CHANNEL_NAME |
Name of the moderators chat channel for bot notifications | 'moderators_only' |
VOICE_CHAPERONE_ENABLED |
Default state of the voice chaperone functionality | True |
ADULT_ROLE_NAMES |
Names of the roles assigned to verified adults (used for voice chaperone) | {'Dads', 'GrownUps'} |
CHILD_ROLE_NAMES |
Names of the roles assigned to children (used for voice chaperone) | {'Kids', 'Bambinos', 'Girls'} |
UPDATE_CHECKING_ENABLED |
Default setting for bot to check for updates | True |
UPDATE_CHECK_REPO_URL |
Repo to check for updates | "https://github.com/BurbSec/JohnnyBot" |
AUTO_UPDATE_ENABLED |
When True, the bot automatically pulls updates that passed CI and don't change config_example.py, then restarts itself. Requires running from a git checkout |
False |
BOT_TIMEZONE |
Timezone for scheduled jobs and event announcements | 'America/Chicago' |
Add your Discord bot token to an OS environment variable called DISCORD_BOT_TOKEN:
export DISCORD_BOT_TOKEN="your_bot_token_here"set DISCORD_BOT_TOKEN=your_bot_token_here$env:DISCORD_BOT_TOKEN="your_bot_token_here"Security Note: For production use, consider using more secure methods like:
- System environment variables
- Docker secrets
- Cloud provider secret management services
python bot.py- The bot should now show as online/active in your Discord server
- Try using a simple command like
/bot_moodto test functionality - Check the console output for any error messages
For production use, consider running the bot as a system service that starts at boot:
Every name and path below is a placeholder — substitute your own.
- Create a service file (
<service-name>is whatever you want to call it):
sudo nano /etc/systemd/system/<service-name>.service- Add the following content:
[Unit]
Description=JohnnyBot Discord Bot
After=network.target
[Service]
Type=simple
User=<user-to-run-as>
WorkingDirectory=<path-to-the-bot-directory>
EnvironmentFile=<path-to-the-bot-directory>/.env
ExecStart=<path-to-python> bot.py
Restart=always
[Install]
WantedBy=multi-user.targetPut the token in the referenced env file rather than an Environment= line in the unit — unit files under /etc/systemd/system are world-readable by default, so an inline token is readable by every account on the machine:
echo 'DISCORD_BOT_TOKEN=<your-token>' > <path-to-the-bot-directory>/.env
chmod 600 <path-to-the-bot-directory>/.env- Enable and start the service:
sudo systemctl enable <service-name>
sudo systemctl start <service-name>- Verify the bot token is correct and properly set as an environment variable
- Check that the bot has the required permissions in your Discord server
- Ensure the bot's role is positioned high enough in the role hierarchy
- Check the console output for error messages
- Verify the bot has all required permissions listed above
- Check that the bot's role is above the roles it needs to manage
- If the bot replies "I don't have the Discord server permissions needed to do that", grant it the missing permission from the table above and retry — it always responds rather than failing silently
- Verify you have the Manage Messages permission (Administrator for
/server_backup,/server_restore,/auto_backup) — most commands are restricted - Check that slash commands are enabled in your server
- Try restarting the bot to refresh command registration
- Check that the bot has "Read Message History" permission
- Verify the user and channel exist and are accessible
- Archives are DM'd as zip attachments; Discord caps attachments at 25 MB, so reduce the
limitor narrow thestart_dateif the dump is too large
If you encounter issues:
-
Check the logs using the
/log_tailcommand (moderators only) - Review the console output for error messages
- Open an issue on the GitHub repository
- Check existing issues for similar problems and solutions
JohnnyBot creates rotating log files in the bot directory. Moderators can use the /log_tail command to get recent log entries sent to their DMs for troubleshooting. The command is restricted because the log records deleted message content from protected channels, member names and IDs, and moderation actions.
JohnnyBot writes these alongside the code. They are gitignored and recreated as needed, but back them up if you care about the state they hold:
| File | Contents |
|---|---|
reminders.json |
Active recurring reminders and their next trigger times |
event_feeds.json |
Feed subscriptions, announcement channels, and posted-event IDs |
event_announce.json |
Per-guild announcement channel configuration |
autoreplies.json |
Autoreply rules |
chaperone_mutes.json |
Members the voice chaperone has muted but not yet unmuted; loaded at startup so a restart does not strand anyone muted |
johnnybot.log |
Rotating log (5 MB, 2 backups) |
Once your bot is running successfully:
- Explore the Commands Reference to learn about all available commands
- Configure reminders for your server's needs
- Set up event feeds if you use external calendars or RSS feeds
- Test moderation commands in a safe environment