diff --git a/ai_commands.py b/ai_commands.py index f2fc345..d044f06 100644 --- a/ai_commands.py +++ b/ai_commands.py @@ -5,7 +5,7 @@ import sys from datetime import datetime from enum import Enum from typing import Optional - +from pathlib import Path import discord import openai import requests @@ -356,9 +356,13 @@ class Events(commands.Cog): self.logger.debug("Wynikowy obrazek pod url: %s", image_url) response = requests.get(image_url, timeout=360) + temp_file_name = message.content + ".png" temp_file_name = GRAPHICS_PATH + message.content + ".png" - + num = 0 + while (Path(temp_file_name)).exists(): + temp_file_name = GRAPHICS_PATH + message.content + str(num) + ".png" + num += 1 with open(temp_file_name, "wb") as dalle_file: dalle_file.write(response.content) self.logger.info("Koniec procedury obrazkowej.")