Giter Club home page Giter Club logo

openai-dalle-discord-bot's Introduction

Simple OpenAI image model Discord bot

A simple and unofficial Discord bot wrapping OpenAI API image models (like DALL·E), build with hikari and lightbulb!

Bot works on servers for everyone, it will respond to DMs only for bot owner.

Requirements

This bot was built with Python 3.12, hikari, lightbulb and openai-python. Full list of Python requirements is in the requirements.txt file, you can use it to install all of them.

Bot permissions

Message content

This bot requires message content privileged gateway intent to function correctly. This is required as bot can respond to all messages in a given channel.

You can enable this content for the whole bot in Discord Developer Portal and specific bot settings.

Currently, bot won't even start without this privileged intent enabled.

Configuration

Configuration is done through a .env file. You can copy example file .env.example as .env and fill required parameters.

cp .env.example .env

Discord bot

Discord bot

Only required parameter is a bot token

BOT_TOKEN='<your secret bot token>'

You can also optionally specify file in which all target channels for start command can be stored:

SOURCES_PERSISTENCE_FILE='<path to basic persistence file>'

Bot will store all channel IDs where automatic responding is configured in this file.

After bot is restarted (if the specified file still exists and wasn't modified) it will keep responding in previously configured channels.

OpenAI API

There are two required parameters - API key and used model.

OPENAI_TOKEN='<your secret API key>'
OPENAI_MODEL='dall-e-3 or dall-e-2'

Through .env you can also configure level of logging of OpenAI API through OPENAI_LOG parameter. You can set it to debug or info.

OPENAI_LOG='debug or info'

Commands

All commands work on servers for everyone and in DMs for bot owner.

  • /start - start generating images for all messages in current channel
  • /quiet_start - start generating images for all messages in current channel without notifying other users
  • /stop - stop generating images automatically
  • /quiet_stop - stop generating images automatically without notifying other users
  • /generate - generate image based on given prompt
  • generate - message command, generate image based on selected message

Running the bot

You can run the bot from the source code directly, or in a Docker container.

From source code

  1. Create a Discord bot
  2. Create OpenAI API key
  3. Install all packages from requirements.txt
  4. Fill .env file
  5. Run main.py file with Python

Docker

  1. Create a Discord bot
  2. Create OpenAI API key
  3. Fill .env file
  4. Run docker compose up -d --build in terminal

Note that .env file is used only for loading environment variables into Docker container through compose. The file itself isn't added to the container.

When using Docker the bot will automatically store channel IDs for purposes of start command in persistence file located in project root.

Disclaimer

This bot is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with OpenAI. This is an independent and unofficial project. Use at your own risk.

openai-dalle-discord-bot's People

Contributors

electronic-mango avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.