The Discord Random Image Bot is your go-to tool for spicing up your Discord server! This bot posts random image URLs from a CSV file hosted on Google Drive, directly into your chosen channel at intervals you set. It's fully customizable, Docker-ready, and super easy to use!
- 🎲 Random Image Posting: Automatically shares a random image URL from a Google Drive CSV file.
- ⏲️ Customizable Interval: Set how often the bot should post using an environment variable.
- 🐳 Dockerized: Simple to deploy anywhere Docker runs.
- 🔐 Secure Configuration: Manage your sensitive data securely with environment variables.
Before you get started, make sure you have the following:
- 🐋 Docker installed.
- 🤖 A Discord bot token from the Discord Developer Portal.
- 🌍 A Google Cloud Project with the Google Drive API enabled and your
credentials.json
downloaded.
-
Create a Google Cloud Project:
- Head over to the Google Cloud Console.
- Enable the Google Drive API.
- Generate OAuth 2.0 credentials and download the
credentials.json
file.
-
Upload Your CSV File:
- Upload a CSV file containing image URLs to Google Drive.
- Share the file with the email linked to your Google Cloud project.
-
Get the File ID:
- Right-click on your CSV file in Google Drive and select "Get link."
- Extract the file ID from the URL (e.g.,
1A2B3C4D5E6F7G8H9I
).
-
Create Your Bot:
- Go to the Discord Developer Portal.
- Create a new application and add a bot to it.
- Copy the bot token for later use.
-
Invite the Bot to Your Server:
- Generate an OAuth2 URL with the bot and the necessary permissions.
- Use this URL to invite the bot to your Discord server.
You'll need the following environment variables to configure your bot:
DISCORD_BOT_TOKEN
: Your Discord bot token.DISCORD_CHANNEL_ID
: The ID of the channel where the bot will post images.GOOGLE_DRIVE_FILE_ID
: The Google Drive file ID for your CSV.GOOGLE_CREDENTIALS_PATH
: Path to yourcredentials.json
inside the Docker container (usually/app/credentials.json
).POST_INTERVAL_SECONDS
: The interval (in seconds) between each image post.
To build the Docker image, navigate to the project directory and run:
docker build -t discord-bot-example .
Run the container with the necessary environment variables:
docker run -e DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN" \
-e DISCORD_CHANNEL_ID="YOUR_CHANNEL_ID" \
-e GOOGLE_DRIVE_FILE_ID="YOUR_FILE_ID" \
-e GOOGLE_CREDENTIALS_PATH="/app/credentials.json" \
-e POST_INTERVAL_SECONDS="30" \ # Adjust the interval as needed
discord-bot-example
Make sure to replace "YOUR_BOT_TOKEN"
, "YOUR_CHANNEL_ID"
, and "YOUR_FILE_ID"
with your actual values. Adjust the POST_INTERVAL_SECONDS
variable to control how often the bot posts.
- Change the Posting Interval: Modify the
POST_INTERVAL_SECONDS
environment variable to set how often the bot should post. - Update the Image List: Simply update the CSV file on Google Drive—no need to restart the bot!
-
Bot Not Posting?:
- Ensure the bot has the correct permissions in the Discord channel.
- Check the bot’s logs for any error messages.
-
Can't Access Google Drive File?:
- Double-check that the file is shared with the correct Google service account.
- Ensure the file ID is correct.