Forge your imagination into reality with ImageSmith - A powerful Discord bot that seamlessly integrates with ComfyUI for intuitive image generation.
ImageSmith is a Discord bot that brings the power of ComfyUI directly to your Discord server. With a user-friendly interface and powerful customization options, it allows users to generate images through simple commands while leveraging ComfyUI's advanced capabilities.
Note: ImageSmith is a workflow executor, not a workflow creator. You'll need to create your own workflows, but the bot makes them easily accessible through Discord's UI. Check out the example workflows in the repository to get started.
- π Direct ComfyUI Integration - Seamless connection with your ComfyUI instance
- π Queue Management - Efficient handling of generation requests
- π οΈ Customizable Workflows - Support for custom ComfyUI workflows
- π Plugin System - Extend functionality through plugins
- π Real-time Progress - Live updates on generation status
- βοΈ Flexible Configuration - Highly customizable settings
- πͺ Hook System - Customize workflow behavior
- Python 3.10+
- Running ComfyUI instance
- Discord Bot Token
Basic Setup
docker run -e DISCORD_TOKEN="<your_discord_token>" ghcr.io/jtyszkiew/imagesmith:latestCustom Configuration
docker run -e DISCORD_TOKEN="<your_discord_token>" \
--mount type=bind,source=./configuration.yml,target=/app/configuration.yml \
ghcr.io/jtyszkiew/imagesmith:latestCustom Configuration & Workflows
docker run -e DISCORD_TOKEN="<your_discord_token>" \
--mount type=bind,source=./configuration.yml,target=/app/configuration.yml \
-v "./custom_workflows:/app/custom_workflows" \
ghcr.io/jtyszkiew/imagesmith:latestImportant: Default workflows use
sd_xl_base_1.0for image generation and Mochi models for video generation. Ensure these are available in your ComfyUI instance.
- Clone & Setup
git clone https://github.com/jtyszkiew/ImageSmith.git
cd ImageSmith
python -m venv venv
source venv/bin/activate # Windows: .\venv\Scripts\activate
pip install -r requirements.txt- Configure
cp configuration.example.yml configuration.yml
# Edit configuration.yml with your settings- Run
python main.py| Command | Description | Parameters |
|---|---|---|
/forge |
Generate image from text | prompt, [workflow], [settings] |
/reforge |
Transform existing image | image, prompt, [workflow], [settings] |
/upscale |
Upscale with modifications | image, prompt, [workflow], [settings] |
/workflows |
List available workflows | - |
# Basic generation
/forge A majestic mountain landscape at sunset
# Using specific workflow
/forge A cyberpunk city --workflow cyberpunk_generator
# With custom settings
/forge A fantasy character --workflow character_generator --settings "change_steps(30);add_lora('fantasy_style', 0.8)"Two settings types: __before and __after are called before each workflow execution.
- name: __before
description: "Default workflow configuration"
code: |
def __before(workflowjson):
import random
workflowjson["4"]["inputs"]["ckpt_name"] = "Juggernaut_X_RunDiffusion.safetensors"
workflowjson["3"]["inputs"]["seed"] = random.randint(0, 2**32 - 1)- name: hd
description: "HD resolution preset"
code: |
def hd(workflowjson):
workflowjson["5"]["inputs"]["width"] = 1280
workflowjson["5"]["inputs"]["height"] = 720Usage: /forge A fantasy character --settings "hd()"
workflows:
forge:
default_for:
channels:
- "forge-default-channel"This setting will make the forge workflow default for the forge-default-channel channel. So you can use /forge
command without specifying the workflow name.
workflows:
forge:
form:
- name: seed
type: text
required: false
description: Seed for the model
message: Provide a seed you would like to use
on_submit: |
def on_submit(workflowjson, value):
workflowjson["65"]["inputs"]["seed"] = value
on_default: |
def on_default(workflowjson):
import random
workflowjson["65"]["inputs"]["seed"] = random.randint(0, 2**32 - 1)You can use the following configurations:
| Name | Type | Description | Required |
|---|---|---|---|
name |
string |
Name of the form field | Yes |
type |
text | resolution | select |
Type of the form field | Yes |
required |
boolean |
Whether the field is required | No |
description |
string |
Description of the field (will be displayed in Discord client) | No |
message |
string |
Message to display when asking for the field (will be displayed in Discord client) | No |
on_submit |
string |
Code to execute when the form is submitted (will pass the provided data), method name should be always called on_submit to be executed |
Yes |
on_default |
string |
If field is not required and no data is provided for given field this method is called so you can always set default value. Method name need to always be on_default. |
No |
Configure access control for workflows and settings:
# Workflow security
workflows:
forge:
security:
enabled: true
allowed_roles: [ "Smith" ]
allowed_users: [ "Smith123" ]
# Setting security
- name: hd
security:
enabled: true
allowed_roles: [ "Smith" ]
allowed_users: [ "Smith123" ]
code: "..."Create custom plugins to extend functionality:
from src.core.plugin import Plugin
class MyPlugin(Plugin):
async def on_load(self):
await super().on_load()
self.bot.hook_manager.register_hook('is.comfyui.client.before_create', self.my_hook)
async def my_hook(self, workflow_json: dict, instances: list):
return workflow_jsonis.comfyui.client.before_createis.comfyui.client.after_createis.security.beforeis.comfyui.client.instance.timeoutis.comfyui.client.instance.reconnect
pip install pytest pytest-asyncio pytest-mock pytest-cov
pytest tests/ -v --cov=./- Fork the repository
- Create feature branch:
git checkout -b feature/AmazingFeature - Commit changes:
git commit -m 'Add AmazingFeature' - Push to branch:
git push origin feature/AmazingFeature - Open a Pull Request
Licensed under the MIT License - see the LICENSE file for details.
- ComfyUI - Image generation backend
- discord.py - Discord integration
This bot is for educational and creative purposes. Users are responsible for ensuring their usage complies with ComfyUI's and Discord's terms of service.
Join our Discord server to see the bot in action and stay updated with the latest developments!
