discord-giveaway-bot

Project: Discord Server Giveaway Bot. Created at https://spectra.codes, which is owned by @Drix10

Stars
1
Committers
1

๐Ÿ“‘ 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/๐Ÿ†” Retrieves a specific giveaway.
    • PUT /api/giveaways/๐Ÿ†” Updates a giveaway.
    • DELETE /api/giveaways/๐Ÿ†” 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