gpt-discord-bot  by openai

Discord bot for OpenAI chat completions

created 2 years ago
1,829 stars

Top 24.1% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides an example Discord bot written in Python that leverages OpenAI's chat completions API for conversational AI and the moderations API for message filtering. It's designed for developers and Discord server administrators looking to integrate advanced AI chat capabilities into their communities, offering features like threaded conversations and customizable bot instructions.

How It Works

The bot utilizes the discord.py library to interact with Discord and the OpenAI Python Library to communicate with OpenAI's models. It supports starting public threads with a /chat command, passing the entire thread history to the model for context-aware responses. Moderation is handled by the OpenAI Moderations API, with configurable thresholds to filter messages.

Quick Start & Requirements

  • Install dependencies: pip install -r requirements.txt
  • Run the bot: python -m src.main
  • Requires Python 3.9+
  • OpenAI API key, Discord bot token, and Discord Client ID are required via environment variables (.env file).
  • Enable "Message Content Intent" for the Discord bot.
  • Official documentation: Discord Project Post

Highlighted Details

  • Supports gpt-3.5-turbo model by default.
  • Customizable bot instructions via config.yaml.
  • Moderation settings adjustable in src/constants.py.
  • Bot remembers conversation history within threads up to a context limit or message count.

Maintenance & Community

  • Feature requests are not accepted for this repository; discussions are encouraged on the Discord Project Post.
  • Pull requests are limited to bug fixes.
  • Community support is available via Discord.

Licensing & Compatibility

  • The repository does not explicitly state a license in the README.

Limitations & Caveats

  • The bot requires specific Discord permissions, including "Send Messages in Threads," "Create Public Threads," and "Manage Threads," which may not be universally granted.
  • The README does not specify compatibility with commercial use or closed-source applications.
Health Check
Last commit

1 year ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
25 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.