Skip to content

markuryy/discord-sd-metadata-bot

 
 

Repository files navigation

Discord Bot for Stable Diffusion Prompt Reader

This is a Discord bot that analyzes image metadata generated by various Stable Diffusion tools. It is based on the Stable Diffusion Prompt Reader project by receyuki.

Features

  • Analyzes image metadata from various Stable Diffusion tools, including A1111 webUI, Easy Diffusion, InvokeAI, NovelAI, ComfyUI, Draw Things, StableSwarmUI, and Fooocus.
  • Monitors all channels in a Discord server for images by default.
  • Allows administrators to exclude specific channels from image analysis using the !exclude command.
  • Reacts with a magnifying glass emoji (🔍) to images with recognized metadata.
  • Reacts with an envelope emoji (✉️) to images without recognized metadata.
  • Sends a direct message to users who react with the magnifying glass emoji, providing the image metadata, including the prompt, negative prompt, settings, and parameters.
  • Sends a direct message to users who react with the envelope emoji, providing the image URL and a link to the original message.
  • Supports multi-image messages and includes image index and total count in the metadata.
  • Implements a cooldown mechanism to prevent spamming of reactions.
  • Allows users to delete messages sent by the bot in their DMs by reacting with the ❌ emoji.

Prerequisites

  • Python 3.7 or higher
  • discord library

Installation

  1. Clone this repository or download the source code.

  2. Install the required discord library using pip:

    pip install discord
    
  3. Create a new file named bot_token.txt in the same directory as the discord_bot.py file.

  4. Open the bot_token.txt file and paste your Discord bot token as the only content in the file.

Usage

  1. Run the discord_bot.py script:

    python discord_bot.py
    
  2. The bot will log in and display a message indicating that it's ready. Press Ctrl+C to stop the bot.

  3. The bot will monitor all channels in the server for images by default.

  4. To exclude a channel from image analysis, use the !exclude command in that channel. Only administrators can use this command.

  5. To include a previously excluded channel, use the !include command in that channel. Only administrators can use this command.

  6. When an image with recognized metadata is posted, the bot will react with a magnifying glass emoji (🔍).

  7. When an image without recognized metadata is posted, the bot will react with an envelope emoji (✉️).

  8. Users can react to the image with the corresponding emoji to receive a direct message containing the image metadata or image URL and original message link.

  9. To delete a message sent by the bot in a DM, users can react to the message with the ❌ emoji.

Configuration

  • The bot prefix is set to !. You can change it by modifying the command_prefix parameter in the discord_bot.py file.

  • The cooldown duration for reactions is set to 5 minutes. You can adjust it by modifying the timedelta(minutes=5) line in the discord_bot.py file.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Acknowledgements

Contact

If you have any questions or need further assistance, please feel free to create an issue.

About

A simple discord bot for viewing Stable Diffusion image metadata. Test it live on The Bulge Discord server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.6%
  • Other 1.4%