Skip to content

AI-Powered Discord Bot ๐Ÿค–

English | ็น้ซ”ไธญๆ–‡

python nextcord openai Ruff tests code-quality codecov license PRs contributors

A comprehensive Discord Bot built with nextcord that provides AI-powered interactions, content processing, and utility features. Features multi-language support and real-time streaming responses. ๐Ÿš€โšก๐Ÿ”ฅ

Suggestions and contributions are always welcome!

โœจ Features

๐Ÿค– AI-Powered Interactions

  • Text Generation: Support for multiple OpenAI models (GPT-4o, o1, o3-mini) with real-time streaming
  • Image Processing: Vision model support with automatic image conversion
  • Web Search: Integrated Perplexity API for real-time web search and summarization

๐Ÿ“Š Content Processing

  • Message Summarization: Smart channel conversation summaries with user filtering
  • Video Downloading: Multi-platform support (YouTube, TikTok, Instagram, X, Facebook)
  • MapleStory Database: Search monsters and items with drop information

๐ŸŒ Multi-Language Support

  • Traditional Chinese (็น้ซ”ไธญๆ–‡)
  • Simplified Chinese (็ฎ€ไฝ“ไธญๆ–‡)
  • Japanese (ๆ—ฅๆœฌ่ชž)
  • English

๐Ÿ”ง Technical Features

  • Main Bot Implementation: The core bot class DiscordBot is implemented in src/bot.py, extending nextcord.ext.commands.Bot with comprehensive initialization, cog loading, and event handling
  • Modular Cog-based architecture
  • Async/await patterns with nextcord
  • Pydantic-based configuration management
  • Comprehensive error handling and logging
  • Docker support with development containers

๐ŸŽฏ Core Commands

Command Description Features
/oai Generate AI text response Multi-model support, image input, optional streaming
/search Web search with AI summary Perplexity API integration
/sum Interactive message summarization User filtering, configurable count
/download_video Multi-platform video downloader Quality options, size validation
/maple_monster Search MapleStory monster drops Detailed monster information
/maple_item Search MapleStory item sources Drop source tracking
/maple_stats MapleStory database statistics Data overview and popular items
/ping Bot performance testing Latency measurement

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10 or higher
  • Discord Bot Token
  • OpenAI API Key
  • Perplexity API Key (for search)

Installation

  1. Clone the repository

    git clone https://github.com/Mai0313/discordbot.git
    cd discordbot
    
  2. Install dependencies using uv

    # Install uv if you haven't already
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # Install dependencies
    uv sync
    
  3. Set up environment variables

    cp .env.example .env
    # Edit .env with your API keys and configuration
    
  4. Run the bot

    uv run python main.py
    

Docker Setup

# Using Docker Compose
docker-compose up -d

# Or build manually
docker build -t discordbot .
docker run -d discordbot

โš™๏ธ Configuration

Required Environment Variables

# Discord Configuration
DISCORD_BOT_TOKEN=your_discord_bot_token
DISCORD_TEST_SERVER_ID=your_test_server_id  # Optional

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_API_TYPE=openai  # or "azure"

# Azure OpenAI (if using Azure)
AZURE_OPENAI_API_KEY=your_azure_key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com

# Perplexity API (for search)
PERPLEXITY_API_KEY=your_perplexity_api_key

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ bot.py              # Main bot entry point
โ”œโ”€โ”€ cogs/               # Command modules
โ”‚   โ”œโ”€โ”€ gen_reply.py    # AI text generation
โ”‚   โ”œโ”€โ”€ gen_search.py   # Web search integration
โ”‚   โ”œโ”€โ”€ summary.py      # Message summarization
โ”‚   โ”œโ”€โ”€ video.py        # Video downloading
โ”‚   โ”œโ”€โ”€ maplestory.py   # MapleStory database queries
โ”‚   โ”œโ”€โ”€ gen_image.py    # Image generation (placeholder)
โ”‚   โ””โ”€โ”€ template.py     # System utilities
โ”œโ”€โ”€ sdk/                # Core business logic
โ”‚   โ”œโ”€โ”€ llm.py          # LLM integration
โ”‚   โ””โ”€โ”€ asst.py         # Assistant API wrapper
โ”œโ”€โ”€ types/              # Configuration models
โ””โ”€โ”€ utils/              # Utility functions

๐Ÿ” Key Features Deep Dive

Multi-Modal AI Support

  • Text and image input processing
  • Automatic image-to-base64 conversion
  • Model-specific constraint handling
  • Streaming response capabilities

Video Download Engine

  • Support for 10+ platforms
  • Quality selection (4K to audio-only)
  • File size validation for Discord limits
  • Progress tracking and error handling

MapleStory Database System

  • Comprehensive monster and item database (192+ monsters)
  • Interactive search with fuzzy matching
  • Multi-language support (Traditional Chinese, Simplified Chinese, Japanese, English)
  • Detailed monster statistics and drop information
  • Item source tracking with visual displays
  • Cached search results for optimal performance

๐Ÿ”’ Privacy Policy

This Discord bot is committed to protecting user privacy and complies with Discordโ€™s Terms of Service and Developer Policy.

๐Ÿ“ฆ Data Collection and Usage

  • No Message Storage: This bot does NOT store, log, or retain any user messages, message content, or chat history beyond the immediate processing needed for a response.
  • No Personal Data Collection: We do not collect, store, or process any personal identifying information (PII) from users.
  • Temporary Processing Only: All inputs are processed in memory only and discarded immediately after the response is generated.
  • No Third-Party Sharing: No user data is shared with any third parties, other than trusted APIs (e.g., OpenAI) for processing the specific user request.

โš™๏ธ Bot Permissions and Intents

This bot uses certain Discord intents solely to provide its core features:

  • Message Content Intent: Required to read and respond to natural-language commands without slash syntax (e.g., keyword detection like "ๆŸฅๆ€ช", "ๆމ่ฝ", etc.).
  • Slash Commands: Used for interactive and explicit command triggers.
  • Embed Links / File Attachments: Used to display structured output and allow interaction with visual content.
  • Presence Intent (if applicable): May be used to improve responsiveness based on online status; not stored.

Users may opt out of interactions via commands like !optout (planned) or by muting the bot.

๐Ÿ” Data Security

  • All API requests are made via secure HTTPS connections.
  • Data is processed only temporarily in memory and never stored on disk or external databases.
  • No long-term logs or analytics based on message or user content are maintained.

๐Ÿ“ฌ Contact and Compliance

If you have privacy concerns or questions about this policy, feel free to:

  • Submit an issue via GitHub
  • Contact the developer through the repository's listed channels

This bot is designed using privacy-by-design principles with a strict minimal-data-handling approach to protect all users.

Last updated: 2025/05/29

Contributors

Contributors

Made with contrib.rocks

For More info, check the Docs