Skip to content

mossly/discord-openai-bot

Repository files navigation

Discord Bot Powered by Advanced AI

This Discord bot leverages modern generative AI API services to facilitate engaging, context-aware interactions on Discord. It not only handles natural language conversations but also supports image generation and web search integration—all through asynchronous API requests.

Features

• Connects seamlessly to Discord using the Discord API.
• Engages users with intelligent, text-based responses generated by an AI language model.
• Offers multiple response modes (detailed, succinct, and creative) to suit your needs.
• Supports referencing previous messages for improved context.
• Integrates optional web search functionality to supplement responses with up-to-date information.
• Includes AI-powered image generation capabilities for creating visuals directly from prompts.

Installation

  1. Clone the repository:

  git clone

  1. Navigate to the repository directory:

  cd

  1. Install the required dependencies:

  pip install -r requirements.txt

  1. Create a .env file in the root directory and add the following environment variables:

  BOT_API_TOKEN=
  OPENAI_API_KEY=
  SYSTEM_PROMPT=
  BOT_TAG=

Replace the placeholder values with your Discord bot token, your AI API key, your desired system prompt, and the tag used to mention the bot.

Usage

  1. Start the bot by running:

  python bot.py

  1. The bot will connect to your Discord server and begin listening for commands.

  2. To interact with the bot, simply mention it with your query. For example:

  @YourBotTag What’s a good recipe for spaghetti carbonara?

  1. To select a different response mode, add the corresponding suffix to your message:   • -v for a detailed reply
      • -c for a creative spin

Example:

  @YourBotTag Explain quantum mechanics -v

  1. For improved context, you can reply to a previous message while mentioning the bot. This allows the bot to reference earlier messages in the conversation as needed.

Contributing

Contributions are welcome! If you’d like to help improve this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Commit and push your modifications.
  4. Open a pull request with a description of your work.

License

This project is licensed under the MIT License.

About

Discord bot that queries LLMs via API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages