From ac761d9284300cf0674b15c7f446f7455ff7ffed Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 31 Jan 2024 13:21:24 -0500 Subject: [PATCH] misc(backup): condensed some code --- backup/backup.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/backup/backup.py b/backup/backup.py index e919a50..70dd513 100644 --- a/backup/backup.py +++ b/backup/backup.py @@ -61,14 +61,10 @@ class Backup(commands.Cog): @commands.is_owner() async def backup_import(self, ctx: commands.Context): """Import your installed repositories and cogs from an export file.""" - if not len(ctx.message.attachments) == 0: - export = await ctx.message.attachments[0].read() - else: - await ctx.send(error("Please provide a valid JSON export file.")) - return try: - export = json.loads(export) - except json.JSONDecodeError: + export_raw = await ctx.message.attachments[0].read() + export = json.loads(export_raw) + except (json.JSONDecodeError, IndexError): await ctx.send(error("Please provide a valid JSON export file.")) return