No description
  • Python 96.9%
  • Dockerfile 3.1%
Find a file
2026-09-29 18:06:59 -05:00
.env.example v0.01 completed 2026-09-29 18:06:59 -05:00
.gitignore v0.01 completed 2026-09-29 18:06:59 -05:00
bot.py v0.01 completed 2026-09-29 18:06:59 -05:00
bot_utilities.py v0.01 completed 2026-09-29 18:06:59 -05:00
docker-compose.yml Add docker-compose.yml 2026-09-28 15:15:15 -05:00
Dockerfile Add Dockerfile 2026-09-28 15:14:59 -05:00
README.md Update README.md 2026-09-28 15:17:28 -05:00
requirements.txt v0.01 completed 2026-09-29 18:06:59 -05:00
sherpaAI.py v0.01 completed 2026-09-29 18:06:59 -05:00

Discord Bot with Image Storage and Persistent Folder

This project is a simple Discord bot built with discord.py that can save image attachments from Discord messages to a persistent folder and list saved images on command. The bot runs inside a Docker container, and a host folder is mounted into the container to store the images, allowing you to access them outside the container as well.


Features

  • Saves image attachments (.png, .jpg, .jpeg, .gif) sent to the bot in Discord.
  • Lists all saved images when the !listimages command is sent.
  • Stores images in a persistent images folder bind-mounted from the host machine.
  • Runs inside a Docker container for easy deployment and isolation.

Project Structure

discord-bot/
├── bot.py              # The bot source code
├── Dockerfile          # Docker image build instructions
├── docker-compose.yml  # Compose file to run the container and mount volumes
├── requirements.txt    # Python dependencies
├── .env                # Environment variables (Discord bot token)
└── images/             # Host folder mounted inside container to persist images

Setup Instructions

1. Clone the Repository

git clone <repository-url>
cd discord-bot

2. Create Discord Bot and Get Token

3. Create .env File

Create a .env file in the project root and add your bot token:

DISCORD_TOKEN=your_bot_token_here

4. Create the Images Folder

Create an images folder in the project root to store the images:

mkdir images

5. Build and Run the Docker Container

Build the Docker image and run the container using Docker Compose:

docker compose up --build

The bot should now connect to Discord.


How It Works

  • Image saving: When the bot receives a message with image attachments, it saves each image file inside the /app/images directory in the container.
  • Persistent storage: The /app/images folder is volume-mounted to the images folder on your host machine, which means all saved images persist on your computer outside the container.
  • Image listing: On receiving the !listimages command, the bot lists all image filenames saved in the images folder.
  • Environment variables: The bot retrieves the Discord token via environment variables loaded from the .env file injected into the container.

Usage

  • Invite the bot to your Discord server.
  • Send a message with image attachments to any channel the bot can read.
  • The bot will confirm saving each image.
  • Send !listimages in a channel to get a list of all saved images.

Stopping the Bot

To stop the bot and remove the container, run:

docker compose down

Notes

  • Ensure the bot has permissions to read and send messages in your Discord server.
  • The bind mount syncs the images folder on your host with the container, allowing manual file management if needed.
  • You can add extra commands or extend functionality by modifying bot.py and rebuilding the image.

Feel free to open issues or request features!