From d0375c3bdbc5541dd84154857a820f17a9cca2cc Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 31 Jan 2024 12:55:35 -0500 Subject: [PATCH] fix(backup): loads the export to see if it's actually valid json or not --- backup/backup.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backup/backup.py b/backup/backup.py index 4cbc618..39a4d09 100644 --- a/backup/backup.py +++ b/backup/backup.py @@ -58,14 +58,16 @@ class Backup(commands.Cog): @backup.command(name='import') @commands.is_owner() - async def backup_import(self, ctx: commands.Context, json: str = None): + async def backup_import(self, ctx: commands.Context, export: str = None): """Import your installed repositories and cogs from an export.""" - if json is None: + if export is None: if not len(ctx.message.attachments) == 0: - json = await ctx.message.attachments[0].read() - else: - await ctx.send(error("Please provide a valid JSON export.")) - return + export = await ctx.message.attachments[0].read() + try: + export = json.loads(json) + except json.JSONDecodeError: + await ctx.send(error("Please provide a valid JSON export.")) + return downloader = ctx.bot.get_cog("Downloader") if downloader is None: