misc(backup): condensed some code
This commit is contained in:
parent
037ef84dcc
commit
ac761d9284
1 changed files with 3 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue