async def info(self, ctx, backup_id): """ Get information about a backup __Arguments__ **backup_id**: The id of the backup or the guild id to for latest automated backup __Examples__ ```{b.prefix}backup info 3zpssue46g``` """ backup = await ctx.client.db.backups.find_one({ "_id": backup_id, "creator": ctx.author.id }) if backup is None: raise ctx.f.ERROR( f"You have **no backup** with the id `{backup_id}`.") backup["data"].pop("members", None) guild = wkr.Guild(backup["data"]) channels = utils.channel_tree(guild.channels) if len(channels) > 1024: channels = channels[:1000] + "\n...\n```" roles = "```{}```".format("\n".join([ r.name for r in sorted( guild.roles, key=lambda r: r.position, reverse=True) ])) if len(roles) > 1024: roles = roles[:1000] + "\n...\n```" raise ctx.f.DEFAULT( embed={ "title": guild.name, "fields": [{ "name": "Created At", "value": utils.datetime_to_string(backup["timestamp"]) + " UTC", "inline": False }, { "name": "Channels", "value": channels, "inline": True }, { "name": "Roles", "value": roles, "inline": True }] })
def _template_info(self, template): guild = wkr.Guild(template["data"]) channels = utils.channel_tree(guild.channels) if len(channels) > 1024: channels = channels[:1000] + "\n...\n```" roles = "```{}```".format("\n".join([ r.name for r in sorted(guild.roles, key=lambda r: r.position, reverse=True) ])) if len(roles) > 1024: roles = roles[:1000] + "\n...\n```" return { "title": template["name"] + ( " ✅" if template["approved"] else " ❌" ), "description": template["description"], "fields": [ { "name": "Creator", "value": f"<@{template['creator_id']}>", "inline": True }, { "name": "Uses", "value": str(template["usage_count"]), "inline": False }, { "name": "Channels", "value": channels, "inline": True }, { "name": "Roles", "value": roles, "inline": True } ] }