mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
[Trivia] Handle FileNotFoundError when adding a custom trivia list (#5950)
This commit is contained in:
parent
d0f22a7773
commit
e0c335eda2
@ -690,8 +690,18 @@ class Trivia(commands.Cog):
|
||||
TRIVIA_LIST_SCHEMA.validate(trivia_dict)
|
||||
|
||||
buffer.seek(0)
|
||||
with file.open("wb") as fp:
|
||||
fp.write(buffer.read())
|
||||
try:
|
||||
with file.open("wb") as fp:
|
||||
fp.write(buffer.read())
|
||||
except FileNotFoundError as e:
|
||||
await ctx.send(
|
||||
_(
|
||||
"There was an error saving the file.\n"
|
||||
"Please check the filename and try again, as it could be longer than your system supports."
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
await ctx.send(_("Saved Trivia list as {filename}.").format(filename=filename))
|
||||
|
||||
def _get_trivia_session(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user