A comprehensive Discord bot for creating, managing, and participating in giveaways within your server, featuring an interactive interface and a web view for giveaway summaries.
- Easy Giveaway Creation: Use the
/giveawayslash command to launch a modal and set up your giveaway details (prize, number of winners, duration, description, optional image). - Interactive Participation: Users can enter giveaways by clicking a "🎉" button on the giveaway message.
- Real-time Updates: The giveaway message embed updates automatically with the remaining time and current entry count.
- Automatic Winner Selection: Winners are randomly selected from the participants when the timer ends.
- Winner Announcements: Winners are announced in the channel and receive a direct message notification.
- Reroll Functionality: Easily reroll winners for a completed giveaway using the
/rerollcommand or by right-clicking the giveaway message and selecting "Reroll Giveaway". - Persistent Storage: Giveaway details, participants, and winners are stored in an SQLite database.
- Web Summary: Each completed giveaway has a dedicated web page (hosted by the included Flask app) showing a summary (host, prize, winners, participants, etc.). The link is added to the giveaway message upon completion.
- Cancellation: Hosts can cancel an ongoing giveaway.
- Leave Option: Participants can leave a giveaway after entering.
- Docker Support: Includes a
Dockerfilefor easy containerization and deployment.
/giveaway [image]: Starts the process to create a new giveaway. Optionally attach an image file./reroll <giveaway_id> [number_of_winners]: Rerolls winners for a specific giveaway message ID. Defaults to 1 winner if not specified. Requires host or admin permissions.- Context Menu -> Reroll Giveaway: Right-click on a completed giveaway message to reroll the original number of winners. Requires host or admin permissions.
The project includes a simple Flask web application (app.py) that serves a summary page for each giveaway. After a giveaway ends, a button linking to this summary page (e.g., yourdomain.com/message_id) is added to the original giveaway message in Discord.
-
Clone the repository:
git clone https://github.com/ReizoZ/GiftMaster.git cd GiftMaster -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Configure Environment Variables:
- Copy
.env.exampleto.env. - Fill in the required values in the
.envfile:DISCORD_TOKEN: Your Discord bot token.DOMAIN: The base URL where the Flask web app will be hosted (e.g.,http://localhost:5000orhttps://yourdomain.com). This is used for the summary links.
- Copy
-
Run the Bot:
python bot.py
-
Run the Web App (in a separate terminal):
python app.py
(Note: The
Dockerfilecombines these into a single container)
- Build the Docker image:
docker build -t giveaway-bot . - Run the Docker container:
(Ensure your
docker run -d --env-file .env -p 5000:5000 --name giveaway-bot-container giveaway-bot
.envfile is correctly populated before running)
(See captain-definition for potential CapRover deployment configurations.)
- discord.py
- Flask
- python-dotenv
- aiohttp (usually included with discord.py)
- aiosqlite (or standard
sqlite3)
This project is licensed under the terms specified in the LICENSE file.
