-
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.7 or higher (tested up to Python 3.13)
- Git for cloning the repository
- A Discord server where you have administrative permissions
- Firewall access to allow inbound connections on TCP port 80 (for message archive hosting)
git clone https://github.com/burbsec/johnnybot.git
cd johnnybot
pip install -r requirements.txt
Note: 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 |
Permission | Required For |
---|---|
Connect | Monitor voice channels for safety features |
Mute Members | Voice channel chaperone functionality |
Move Members | Voice channel management |
- The bot does NOT require Administrator permissions
- 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
Open the config.py
file in a text editor and modify the following constants according to your server's setup:
# Required Configuration
MODERATOR_ROLE_NAME = "Moderator" # Name of the moderator role
PROTECTED_CHANNELS = ["announcements", "rules"] # Read-only channels
MODERATORS_CHANNEL_NAME = "moderators" # Channel for bot notifications
Setting | Description | Example |
---|---|---|
MODERATOR_ROLE_NAME |
Name of the moderator role. Necessary for mods to use bot commands | "Moderator" |
PROTECTED_CHANNELS |
List 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" |
VOICE_CHAPERONE_ENABLED |
Default state of the voice chaperone functionality | False |
ADULT_ROLE_NAMES |
Name of the role assigned to verified adults (used for voice chaperone) | ['Dads', 'GrownUps'] |
CHILD_ROLE_NAMES |
Name of the role assigned to children (used for voice chaperone) | ['Kids', 'Bambinos', 'Girls'] |
HOST_IP |
IP address of the interface to use for the /message_dump HTTP server |
"172.116.0.73" |
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" |
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_mood
to 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:
- Create a service file:
sudo nano /etc/systemd/system/johnnybot.service
- Add the following content:
[Unit]
Description=JohnnyBot Discord Bot
After=network.target
[Service]
Type=simple
User=your_username
WorkingDirectory=/path/to/johnnybot
Environment=DISCORD_BOT_TOKEN=your_token_here
ExecStart=/usr/bin/python3 bot.py
Restart=always
[Install]
WantedBy=multi-user.target
- Enable and start the service:
sudo systemctl enable johnnybot
sudo systemctl start johnnybot
- 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
- Ensure the moderator role name in
config.py
matches your server's role
- Verify you have the moderator role (most commands are restricted)
- Check that slash commands are enabled in your server
- Try restarting the bot to refresh command registration
- Ensure your firewall allows inbound connections on TCP port 80
- Check that the bot has "Read Message History" permission
- Verify the user and channel exist and are accessible
If you encounter issues:
-
Check the logs using the
/log_tail
command - 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. Use the /log_tail
command to get recent log entries sent to your DMs for troubleshooting.
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
- Test moderation commands in a safe environment