π A production-ready Discord giveaway bot with sharding support (via discord-hybrid-sharding), slash commands, and simple JSON-backed persistence.
Built to be fast, easy to run, and simple to customize.
β€οΈβ€οΈ Make sure to SUBSCRIBE to ZarScape if this bot helps you β€οΈβ€οΈ
- Sharded architecture using discord-hybrid-sharding for scale
- Slash commands (auto-registered on startup)
- JSON-backed per-guild giveaway persistence (stored in
data/) - Uses modern Discord.js v14 and supports Message Content and Reaction-based interactions
- Demo / Screenshots
- Prerequisites
- Install
- Configuration
- Running the Bot (Development)
- Production / Deployment Notes
- Data Storage
- Permissions
- Troubleshooting
- Contributing
- Support
- License
- Node.js >= 16.9.0 (Node 18 LTS recommended)
- npm
- A Discord application with a bot token and the Application (client) ID
This project depends on the versions listed in package.json and was built using discord.js v14 and discord-hybrid-sharding.
Clone the repository and install dependencies:
git clone https://github.com/ZarScape/giveaway-discord-app.git
cd "giveaway-discord-app"
npm installCreate a .env file in the project root with the following values OR rename .env.example to .env and edit:
# .env
TOKEN=your_bot_token_here
CLIENTID=your_application_client_idTOKENβ your bot token from the Discord Developer PortalCLIENTIDβ the Application (Client) ID (used when registering slash commands)
There is a small runtime configuration file at src/config/config.json. By default it contains a color value used by embeds β update it to match your branding.
Notes:
- The slash command handler will abort if either
TOKENorCLIENTIDis missing (seesrc/handlers/slash.js). - The bot will exit with an error message if the token is missing or invalid (see
src/zar.js).
Start the bot (PowerShell):
# Recommended: create .env first and then run
npm startThe start script runs node src/zar.js, which launches the cluster manager and spawns worker clusters.
- Ensure the host has sufficient file permissions to write the
data/directory (giveaway state is stored there). - If you deploy globally-registered slash commands, note that changes may take up to an hour to fully propagate. For quicker testing, adapt the registration to use guild-specific registration.
Giveaways and related state are stored in data/<GUILD_ID>/giveaways/ as JSON files (see data/ directory). Back this folder up if the data is important. The bot expects the folder structure to exist or be creatable by the runtime user.
If you prefer a database (SQLite, MongoDB, etc.), you can replace the JSON persistence with DB calls in src/Giveaway/giveawayUtils.js and related files.
Recommended bot permissions in the server: Send Messages, Embed Links, Read Message History, Manage Messages (if you want the bot to remove/close messages), Use Slash Commands. Adjust according to your use-case.
TOKEN not found in .env fileβ create a.envfile at the project root withTOKENset.Invalid Discord token providedβ verify the token in the.envfile is correct and not expired/rotated.TOKEN or CLIENTID missing in .envduring slash registration β ensure both values exist in.env.- Slash commands not appearing immediately β global commands can take up to an hour to register. For faster testing use guild commands.
Contributions are welcome. If you'd like to contribute:
- Fork the repository
- Create a feature branch
- Add tests or a small demo where appropriate
- Open a pull request describing your changes
If you add persistence changes (DB instead of JSON) please include migration instructions.
Join the community or request help via the project's Discord: https://discord.gg/6YVmxA4Qsf
This project includes a LICENSE file in the repository root. Refer to it for license terms.
Authored by ZarScape
β€οΈ Make sure to SUBSCRIBE to ZarScape if this bot helps you: https://www.youtube.com/@ZarScape
