Skip to content

coslynx/discord-server-moderation-bot

Repository files navigation


discord-server-moderation-bot

Discord moderation bot with advanced features for server management.

Developed with the software and tools below.

Language: TypeScript Framework: Discord.js Database: MongoDB AI: OpenAI API

git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

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

πŸ“ Overview

This repository houses "ModerationBot," a Discord bot designed for server moderation and management. It leverages advanced features like automated message filtering, role management, moderation commands, user logging, customizable rules, and more. ModerationBot helps cultivate a positive and organized environment for your Discord communities.

πŸ“¦ Features

Feature Description
βš™οΈ Architecture The codebase follows a modular architecture, separating different functionalities into distinct modules for improved organization and maintainability.
πŸ“„ Documentation This README provides a comprehensive overview of the bot's features, installation, usage, and development details.
πŸ”— Dependencies The bot utilizes essential libraries and packages like Discord.js, Mongoose, OpenAI API, and other tools for handling Discord interactions, database management, and advanced AI functionality.
🧩 Modularity Code is structured into modules for commands, utilities, events, models, and services, promoting code reusability and ease of maintenance.
πŸ§ͺ Testing Unit tests are implemented using Jest to ensure the bot's functionality is correct and reliable.
⚑️ Performance The bot's design prioritizes performance, employing efficient data structures and algorithms for responsiveness.
πŸ” Security Security measures include input validation, data sanitization, and secure API handling to protect user data and server integrity.
πŸ”€ Version Control The project uses Git for version control, facilitating collaboration and managing code changes.
πŸ”Œ Integrations The bot integrates with the Discord API, MongoDB database, and OpenAI API for seamless functionality.
πŸ“Ά Scalability The architecture is designed to scale efficiently, allowing for handling a large number of users and messages.

πŸ“‚ Structure

β”œβ”€β”€ .env
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ postcss.config.js
β”œβ”€β”€ tailwind.config.js
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ .github
β”‚   └── workflows
β”‚       └── main.yml
└── src
    β”œβ”€β”€ index.ts
    β”œβ”€β”€ commands
    β”‚   β”œβ”€β”€ moderation.ts
    β”‚   β”œβ”€β”€ roles.ts
    β”‚   β”œβ”€β”€ logging.ts
    β”‚   └── customRules.ts
    β”œβ”€β”€ utils
    β”‚   β”œβ”€β”€ config.ts
    β”‚   β”œβ”€β”€ database.ts
    β”‚   β”œβ”€β”€ nlp.ts
    β”‚   β”œβ”€β”€ discord.ts
    β”‚   └── logger.ts
    β”œβ”€β”€ events
    β”‚   β”œβ”€β”€ messageCreate.ts
    β”‚   β”œβ”€β”€ guildMemberAdd.ts
    β”‚   └── guildMemberRemove.ts
    β”œβ”€β”€ models
    β”‚   β”œβ”€β”€ user.ts
    β”‚   β”œβ”€β”€ guild.ts
    β”‚   └── message.ts
    └── services
        β”œβ”€β”€ moderationService.ts
        β”œβ”€β”€ roleService.ts
        β”œβ”€β”€ loggingService.ts
        └── customRulesService.ts

πŸ’» Installation

πŸ”§ Prerequisites

  • Node.js (v18 or later)
  • npm (or yarn)
  • MongoDB

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/spectra-ai-codegen/discord-server-moderation-bot.git
  2. Navigate to the project directory:
    cd discord-server-moderation-bot
  3. Install dependencies:
    npm install
  4. Set up environment variables:
    • Create a .env file in the root directory.
    • Add the following environment variables:
      DISCORD_TOKEN=your_discord_bot_token
      MONGO_URI=mongodb://your_mongodb_host:27017/your_database_name
      OPENAI_API_KEY=your_openai_api_key
      
  5. Start the bot:
    npm start

πŸ—οΈ Usage

To use ModerationBot, follow these steps:

  1. Invite the bot to your server:
  2. Grant permissions:
    • When inviting the bot, ensure you grant it the necessary permissions for moderation, such as "Kick Members," "Ban Members," "Manage Channels," and "Manage Roles."
  3. Configure settings (optional):
    • Use the bot's commands or a custom dashboard (if implemented) to set up custom rules, filtering options, and other configurations.

🌐 Hosting

πŸš€ Deployment Instructions

  1. Build the application:
    npm run build
  2. Deploy to a cloud platform:
    • Heroku, AWS, Google Cloud, or any other hosting platform of your choice.
  3. Set up environment variables on the hosting platform:
    • Ensure the environment variables DISCORD_TOKEN, MONGO_URI, and OPENAI_API_KEY are correctly set in the hosting environment.

πŸ“„ License

This project is licensed under the MIT License.

πŸ‘ Authors

🌐 Spectra.Codes

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