mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Catch exceptions in [p]backup (#2363)
Resolves #2354. Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
parent
78e4b578e2
commit
7973babe4b
@ -1142,6 +1142,9 @@ class Core(commands.Cog, CoreLogic):
|
|||||||
await ctx.send(
|
await ctx.send(
|
||||||
_("A backup has been made of this instance. It is at {}.").format(backup_file)
|
_("A backup has been made of this instance. It is at {}.").format(backup_file)
|
||||||
)
|
)
|
||||||
|
if backup_file.stat().st_size > 8_000_000:
|
||||||
|
await ctx.send(_("This backup is to large to send via DM."))
|
||||||
|
return
|
||||||
await ctx.send(_("Would you like to receive a copy via DM? (y/n)"))
|
await ctx.send(_("Would you like to receive a copy via DM? (y/n)"))
|
||||||
|
|
||||||
pred = MessagePredicate.yes_or_no(ctx)
|
pred = MessagePredicate.yes_or_no(ctx)
|
||||||
@ -1152,10 +1155,18 @@ class Core(commands.Cog, CoreLogic):
|
|||||||
else:
|
else:
|
||||||
if pred.result is True:
|
if pred.result is True:
|
||||||
await ctx.send(_("OK, it's on its way!"))
|
await ctx.send(_("OK, it's on its way!"))
|
||||||
|
try:
|
||||||
async with ctx.author.typing():
|
async with ctx.author.typing():
|
||||||
await ctx.author.send(
|
await ctx.author.send(
|
||||||
_("Here's a copy of the backup"), file=discord.File(str(backup_file))
|
_("Here's a copy of the backup"),
|
||||||
|
file=discord.File(str(backup_file)),
|
||||||
)
|
)
|
||||||
|
except discord.Forbidden:
|
||||||
|
await ctx.send(
|
||||||
|
_("I don't seem to be able to DM you. Do you have closed DMs?")
|
||||||
|
)
|
||||||
|
except discord.HTTPException:
|
||||||
|
await ctx.send(_("I could not send the backup file."))
|
||||||
else:
|
else:
|
||||||
await ctx.send(_("OK then."))
|
await ctx.send(_("OK then."))
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user