comfyui discord bot
for the last year or two i’ve had a custom discord bot that i use to play around with the latest ai tools with friends in a convenient format i can reach from all my devices anywhere. self hosted discord bots are a ridiculously good service (maybe too good, i’m waiting for it to get ruined somehow) and a great project for practicing coding.
currently my comfy bot repos are private, i’ll probably public them at some point but for now i can share the structure i used because i think it’s pretty flexible and helpful.
lightweight ‘always’ bot
- watches your discord for some trigger event
- trigger could be: any message in a certain channel, message starting with a certain phrase, a slash command, adding a react to a message…
- when triggered it adds the message to a queue (ie by saving it in a db as a row)
- stays on all the time so it doesn’t miss any events
- write this whatever language you want, it’s not going to be doing much
‘worker’ bot/app
- program to run locally that communicates with local ComfyUI API to generate images
- fetches message/prompt from your queue, processes it with a comfyui workflow, then sends a response image straight to discord in reply to the message
this setup can be used for any heavy task. it excels for AI because a cloud model means you have to pay for storing the model and any involved tools/loras and when you spin up a machine you have to wait for those to download. this system can also work with multiple ‘workers’ if you have a few machines you want to share work, or have friends that want to contribute to the rendering workload