-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
33 lines (27 loc) · 902 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from discord import Intents
import discord
from discord.ext import commands
from dotenv import load_dotenv
import os
import gc
import re
from StableDiffusionModel import generate
load_dotenv()
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(
command_prefix="!",
description="GAI generates the image.",
intents=intents,
)
@bot.command()
async def create(ctx, *, prompt):
msg = await ctx.send(f"「{prompt}」\n 生成中・・・")
generate(prompt=prompt)
# if(re.search(r'[ぁ-んァ-ン]', prompt)):
# await msg.edit(content=f"「{prompt}」\n生成が完了しました \n文章は以下のように自動で翻訳されました\n{text}")
# else:
await msg.edit(content=f"「{prompt}」\n生成が完了しました")
await ctx.send(file=discord.File("./test.png"))
gc.collect()
bot.run(os.environ["DISCORD_TOKEN"])