forked from blizzthewolf/SeaCogs
fix(backup): loads the export to see if it's actually valid json or not
This commit is contained in:
parent
26b085231b
commit
d0375c3bdb
1 changed files with 8 additions and 6 deletions
|
@ -58,12 +58,14 @@ class Backup(commands.Cog):
|
||||||
|
|
||||||
@backup.command(name='import')
|
@backup.command(name='import')
|
||||||
@commands.is_owner()
|
@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."""
|
"""Import your installed repositories and cogs from an export."""
|
||||||
if json is None:
|
if export is None:
|
||||||
if not len(ctx.message.attachments) == 0:
|
if not len(ctx.message.attachments) == 0:
|
||||||
json = await ctx.message.attachments[0].read()
|
export = await ctx.message.attachments[0].read()
|
||||||
else:
|
try:
|
||||||
|
export = json.loads(json)
|
||||||
|
except json.JSONDecodeError:
|
||||||
await ctx.send(error("Please provide a valid JSON export."))
|
await ctx.send(error("Please provide a valid JSON export."))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue