fix(backup): remove support for message content based json loading
This commit is contained in:
parent
c2aa674bff
commit
c07c7317f4
2 changed files with 4 additions and 11 deletions
|
@ -22,4 +22,4 @@ Exports a JSON list of all of your added repositories, and their installed cogs.
|
|||
|
||||
- Usage: `[p]backup import [json]`
|
||||
|
||||
Imports, reinstalls, and reloads cogs from a valid export. Requires either the json export to be provided in the command's message content or to be attached to the command's message. Ignores itself and PyLav cogs.
|
||||
Imports, reinstalls, and reloads cogs from a valid export. Requires the JSON export to be attached to the invoking message as an attachment. Ignores itself and PyLav cogs.
|
||||
|
|
|
@ -59,12 +59,12 @@ class Backup(commands.Cog):
|
|||
|
||||
@backup.command(name='import')
|
||||
@commands.is_owner()
|
||||
async def backup_import(self, ctx: commands.Context, *, export: str = None):
|
||||
"""Import your installed repositories and cogs from an export."""
|
||||
async def backup_import(self, ctx: commands.Context):
|
||||
"""Import your installed repositories and cogs from an export file."""
|
||||
if export is None and not len(ctx.message.attachments) == 0:
|
||||
export = await ctx.message.attachments[0].read()
|
||||
try:
|
||||
export = json.loads(self.extract_json_from_codeblock(export))
|
||||
export = json.loads(export)
|
||||
except json.JSONDecodeError:
|
||||
await ctx.send(error("Please provide a valid JSON export."))
|
||||
return
|
||||
|
@ -73,10 +73,3 @@ class Backup(commands.Cog):
|
|||
if downloader is None:
|
||||
await ctx.send(error(f"You do not have the `Downloader` cog loaded. Please run `{ctx.prefix}load downloader` and try again."))
|
||||
return
|
||||
|
||||
def extract_json_from_codeblock(self, text):
|
||||
match = re.match(r"```(?:\w+)?\n(.*?)\n```", text, re.DOTALL)
|
||||
if match:
|
||||
return match.group(1).strip()
|
||||
else:
|
||||
return text
|
||||
|
|
Loading…
Reference in a new issue