Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craiyon API Image generator PR #156

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
33 changes: 33 additions & 0 deletions bot/commands/fun/gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from io import BytesIO
import base64
import time
from craiyon import Craiyon
from bot.commands.fun.__blocked_prompts import blocked
from bot.config import Config, Embed
from bot.base import Command


class cmd(Command):
""" A discord command instance. """
#
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name = "gen"
usage = "gen <*prompt>"
description = "Uses the Craiyon AI API to generate an image with a given prompt"

async def execute(self, arguments, message) -> None:
prompt = arguments[0]
if prompt.lower() in blocked:
await message.channel.send("I'm not generating that you meanie >:( It's NSFW! Try something else!")
return

loadingE = Embed(title=f"Image {prompt} currently generating, please wait a moment!")
loadingM = await message.channel.send(embed=loadingE)

generator = Craiyon()
result = generator.generate(prompt)
images = result.images
embed = Embed(title="Here is the generated image")
embed.set_image(url=images[0])

await loadingM.delete()
await message.channel.send(embed=embed)
25 changes: 25 additions & 0 deletions bot/events/blocked_prompts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
blocked = [
"nsfw",
"pussy",
"gore",
"murder",
"penis",
"cat",
"emacs",
"porn",
"vagina",
"dick",
"sex",
"intercourse",
"bondage",
"bdsm",
"fetish",
"kink",
"pegging",
"peg",
"anal",
"vaginal",
"erotic",
"notepad

]