sparkles-cat-bot/DOCKER-GUIDE.md

2.9 KiB

Docker Guide for Cat Bot

This guide will help you run the Discord cat bot using Docker, which provides an isolated and consistent environment for the bot to run.

Prerequisites

  • Docker installed on your system
  • Docker Compose installed on your system
  • A valid Discord bot token in your .env file

Setup

  1. Make sure your .env file is properly configured with your Discord bot token and other settings:
DISCORD_TOKEN=your_discord_bot_token

# Message response chance (0-100)
MESSAGE_RESPONSE_CHANCE=10

# Voice channel settings
MIN_VOICE_JOIN_INTERVAL=300
MAX_VOICE_JOIN_INTERVAL=1800
MIN_VOICE_STAY_DURATION=60
MAX_VOICE_STAY_DURATION=300
MIN_VOICE_MEOW_INTERVAL=5
MAX_VOICE_MEOW_INTERVAL=30

# Cat personalization
CAT_PRONOUN=their
  1. Add your cat sound files to the src/audio directory (create it if it doesn't exist):
    • meow1.mp3
    • meow2.mp3
    • meow3.mp3
    • purr.mp3
    • hiss.mp3
    • yowl.mp3

Running the Bot

Easy Method

Use the included helper script:

# Make it executable
chmod +x run-docker.sh

# Run it
./run-docker.sh

This script will set the correct user permissions, build, and run the container showing logs.

Manual Method

From the project root directory:

# Export your user ID and group ID
export UID=$(id -u)
export GID=$(id -g)

# Start the container
docker-compose up -d

# View logs
docker-compose logs -f

Stopping the Bot

To stop the bot:

docker-compose down

Updating the Bot

If you make changes to the bot code:

  1. Stop the bot: docker-compose down
  2. Rebuild the image: docker-compose build
  3. Start the bot again: docker-compose up -d

Troubleshooting

Audio File Issues

If the bot isn't playing sounds in voice channels:

  1. Check that your audio files exist in the src/audio directory
  2. Verify they're in MP3 format and match the expected filenames
  3. Look at the container logs to see if the files are being detected:
    docker-compose logs | grep "audio"
    

Bot Token Issues

If the bot can't connect to Discord:

  1. Make sure your .env file is properly mounted in the container
  2. Check that your token is valid and privileged intents are enabled
  3. Verify logs for any connection errors:
    docker-compose logs
    

File Permission Issues

If you encounter file permission problems:

  1. Use the run-docker.sh script which sets proper user IDs
  2. Or manually set the user ID when running:
    export UID=$(id -u) GID=$(id -g)
    docker-compose up -d
    

Container Not Starting

If the container fails to start or continuously restarts:

  1. Check the logs: docker-compose logs
  2. Verify your container has network access to reach Discord's servers
  3. Make sure you have ffmpeg installed in the container:
    docker-compose exec cat-bot apk info | grep ffmpeg