mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 13:34:40 +00:00
add exception handling
This commit is contained in:
+10
-2
@@ -2,6 +2,7 @@
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
import random
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
@@ -373,8 +374,15 @@ class Events(commands.Cog):
|
||||
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)
|
||||
try:
|
||||
with open(temp_file_name, "wb") as dalle_file:
|
||||
dalle_file.write(response.content)
|
||||
except OsError:
|
||||
temp_file_name = "oserror.png"
|
||||
with open(temp_file_name, "wb") as dalle_file:
|
||||
dalle_file.write(response.content)
|
||||
|
||||
|
||||
self.logger.info("Koniec procedury obrazkowej.")
|
||||
fnord = discord.File(
|
||||
temp_file_name, spoiler=False, description=message.content
|
||||
|
||||
Reference in New Issue
Block a user