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