Skip to content

coslynx/discord-giveaway-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


discord-giveaway-bot

A Discord bot designed to automate and streamline giveaways

Developed with the software and tools below.

Framework: React Frontend: Javascript, HTML, CSS Backend: Node.js LLMs: Custom, Gemini, OpenAI

git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

  • πŸ“ Overview
  • πŸ“¦ Features
  • πŸ“‚ Structure
  • πŸ’» Installation
  • πŸ—οΈ Usage
  • 🌐 Hosting
  • πŸ“„ License
  • πŸ‘ Authors

πŸ“ Overview

This repository contains a Discord giveaway bot project designed to simplify giveaway management on Discord servers. It provides a comprehensive solution with features like automated giveaway creation, entry management, winner selection, and announcement capabilities. The project is built using a robust and scalable tech stack, including React, Node.js, PostgreSQL, and custom AI models.

πŸ“¦ Features

Feature Description
βš™οΈ Architecture The codebase utilizes a modular architecture, with distinct directories for commands, events, services, models, and utilities, ensuring maintainability and scalability.
πŸ“„ Documentation This README file provides a comprehensive overview of the project, its features, dependencies, installation instructions, and usage examples.
πŸ”— Dependencies The project relies on various external libraries such as Discord.js for interacting with the Discord API, Prisma for database management, Next.js for frontend development, and other packages for functionality.
🧩 Modularity The codebase is highly modular, with each component and functionality separated into dedicated directories and files, promoting code reusability and maintainability.
πŸ§ͺ Testing Implement unit tests using Jest or React Testing Library to ensure the reliability and robustness of the codebase.
⚑️ Performance The bot is optimized for performance using caching mechanisms, efficient database queries, and asynchronous operations to minimize latency and improve responsiveness.
πŸ” Security Security measures include input validation, sanitization, and secure API integration, protecting against vulnerabilities and ensuring data privacy.
πŸ”€ Version Control The project uses Git for version control, with a GitHub Actions workflow for automated build and deployment processes.
πŸ”Œ Integrations The bot seamlessly integrates with the Discord API for interactions and data retrieval. It may also integrate with external services like payment gateways or prize delivery platforms.
πŸ“Ά Scalability The bot is designed for scalability to handle increasing user traffic and data volume. This includes database optimization, caching, and the potential for horizontally scaling the server infrastructure.

πŸ“‚ Structure

β”œβ”€β”€ src
β”‚   β”œβ”€β”€ commands
β”‚   β”‚   β”œβ”€β”€ create.js
β”‚   β”‚   β”œβ”€β”€ enter.js
β”‚   β”‚   β”œβ”€β”€ end.js
β”‚   β”‚   β”œβ”€β”€ winners.js
β”‚   β”‚   β”œβ”€β”€ help.js
β”‚   β”‚   └── dashboard.js
β”‚   β”œβ”€β”€ events
β”‚   β”‚   β”œβ”€β”€ ready.js
β”‚   β”‚   β”œβ”€β”€ message.js
β”‚   β”‚   └── interactionCreate.js
β”‚   β”œβ”€β”€ services
β”‚   β”‚   β”œβ”€β”€ giveawayService.js
β”‚   β”‚   β”œβ”€β”€ databaseService.js
β”‚   β”‚   β”œβ”€β”€ discordService.js
β”‚   β”‚   └── notificationService.js
β”‚   β”œβ”€β”€ models
β”‚   β”‚   β”œβ”€β”€ Giveaway.js
β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   └── Prize.js
β”‚   β”œβ”€β”€ utils
β”‚   β”‚   β”œβ”€β”€ commandHandler.js
β”‚   β”‚   β”œβ”€β”€ logger.js
β”‚   β”‚   β”œβ”€β”€ errorHandler.js
β”‚   β”‚   └── randomWinnerSelector.js
β”‚   β”œβ”€β”€ config
β”‚   β”‚   β”œβ”€β”€ env.config.js
β”‚   β”‚   └── database.config.js
β”‚   β”œβ”€β”€ routes
β”‚   β”‚   β”œβ”€β”€ api.js
β”‚   β”‚   └── authRoutes.js
β”‚   β”œβ”€β”€ middleware
β”‚   β”‚   β”œβ”€β”€ authentication.js
β”‚   β”‚   β”œβ”€β”€ authorization.js
β”‚   β”‚   └── logging.js
β”‚   └── prisma
β”‚       └── schema.prisma
β”œβ”€β”€ public
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ favicon.ico
β”‚   β”œβ”€β”€ robots.txt
β”‚   └── manifest.json
β”œβ”€β”€ next.config.js
β”œβ”€β”€ tsconfig.json
└── README.md

πŸ’» Installation

πŸ”§ Prerequisites

  • Node.js (v18+)
  • npm
  • Docker

πŸš€ Setup Instructions

  1. Clone the repository:
    • git clone https://github.com/spectra-ai-codegen/discord-giveaway-bot.git
  2. Navigate to the project directory:
    • cd discord-giveaway-bot
  3. Install dependencies:
    • npm install

πŸ—οΈ Usage

πŸƒβ€β™‚οΈ Running the Project

  1. Start the development server:
    • npm start
  2. Open your browser and navigate to http://localhost:3000.

βš™οΈ Configuration

Adjust configuration settings in config.js or .env.

πŸ“š Examples

  • πŸ“ Example 1: Creating a new giveaway

    • /create command with arguments for prize, duration, entry requirements, and number of winners.
  • πŸ“ Example 2: Entering a giveaway

    • /enter command with the giveaway ID.
  • πŸ“ Example 3: Ending a giveaway

    • /end command with the giveaway ID (only for admins).
  • πŸ“ Example 4: Viewing winners

    • /winners command with the giveaway ID.
  • πŸ“ Example 5: Accessing the admin dashboard

    • /dashboard command (redirects to the web interface).

    🌐 Hosting

    πŸš€ Deployment Instructions

    Heroku Deployment

    1. Install the Heroku CLI:
      • npm install -g heroku
    2. Login to Heroku:
      • heroku login
    3. Create a new Heroku app:
      • heroku create
    4. Deploy the code:
      • git push heroku main

    Environment Variables

    • DISCORD_BOT_TOKEN: Your Discord bot token.
    • DATABASE_URL: Your PostgreSQL database connection string.
    • NEXTAUTH_SECRET: Your NextAuth.js secret key.

    πŸ“œ API Documentation

    πŸ” Endpoints

    • POST /api/giveaways: Creates a new giveaway.
    • GET /api/giveaways/:id: Retrieves a specific giveaway.
    • PUT /api/giveaways/:id: Updates a giveaway.
    • DELETE /api/giveaways/:id: Deletes a giveaway.
    • POST /api/giveaways/:id/enter: Enters a giveaway.
    • POST /api/giveaways/:id/end: Ends a giveaway.

    πŸ”’ Authentication

    Use JWT tokens for authentication to access the API.

    πŸ“ Examples

    • curl -X POST -H "Content-Type: application/json" -d '{"prize": "Discord Nitro", "duration": 86400, "entryRequirements": [], "numberOfWinners": 1}' http://localhost:3000/api/giveaways

    πŸ“œ License

    This project is licensed under the GNU AGPLv3.

    πŸ‘₯ Authors

    🌐 Spectra.Codes

    Why only generate Code? When you can generate the whole Repository!