fixed bug of neg prompt file potentially not existing

This commit is contained in:
phixxy 2024-01-19 18:55:18 -08:00
parent fdf98224b1
commit de7f03bb58

View file

@ -257,11 +257,12 @@ class StableDiffusion(commands.Cog):
url=f"{url}/sdapi/v1/txt2img"
prompt = ctx.message.content.split(" ", maxsplit=1)[1]
key_value_pairs, prompt = self.extract_key_value_pairs(prompt)
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
try:
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
with open(neg_prompt_file, 'r') as f:
negative_prompt = f.readline()
except:
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
with open(neg_prompt_file, 'w') as f:
f.writelines("")
negative_prompt = ""