big ol if else to make this only work in the stable-diffusion channel

This commit is contained in:
Luke Robles 2022-10-12 17:38:35 -07:00
parent 650a23c2c7
commit 608202b259

View File

@ -97,48 +97,51 @@ class ActualUtils(commands.Cog):
required=False, required=False,
), ),
): ):
import socket
import stable_diffusion
port = "7860" if ctx.channel.name == "stable-diffusion":
ip = "192.168.1.80" import socket
steps = 20 import stable_diffusion
# Send my requests to my gaming computer with the 3080 (if its up) port = "7860"
if ctx.author.id == 144986109804412928: ip = "192.168.1.80"
ip = "192.168.1.188" steps = 20
steps = 60
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
try:
s.connect((ip, int(port)))
except:
ip = "192.168.1.80"
try: # Send my requests to my gaming computer with the 3080 (if its up)
await ctx.defer() if ctx.author.id == 144986109804412928:
original_message = await ctx.followup.send( ip = "192.168.1.188"
"Please be patient, I'm generating your image" steps = 60
) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
file_path = await stable_diffusion.generate_image( s.settimeout(1)
ip=ip, try:
port=port, s.connect((ip, int(port)))
positives=positive_prompt, except:
negatives=negative_prompt or None, ip = "192.168.1.80"
steps=steps, try:
) await ctx.defer()
await original_message.edit( original_message = await ctx.followup.send(
content="", "Please be patient, I'm generating your image"
file=discord.File( )
file_path, file_path = await stable_diffusion.generate_image(
filename="unknown.png", ip=ip,
), port=port,
) positives=positive_prompt,
os.remove(file_path) negatives=negative_prompt or None,
except Exception as e: steps=steps,
await ctx.reply( )
"Stable diffusion isnt running right now, sorry.\n%s" % e, await original_message.edit(
) content="",
file=discord.File(
file_path,
filename="unknown.png",
),
)
os.remove(file_path)
except Exception as e:
await ctx.reply(
"Stable diffusion isnt running right now, sorry.\n%s" % e,
)
else:
await ctx.respond("You can only do that in the stable-diffusion channel")
@commands.has_role("Track day gamers") @commands.has_role("Track day gamers")
@commands.slash_command( @commands.slash_command(