def embed_from_json(self, ctx, *, js_text: str):
"""Send an embed from JSON.
Usage: embed_from_json [json]"""
echeck_perms(ctx, ('bot_owner',))
class SemiEmbed:
def __init__(self, obj):
self.obj = obj
def to_dict(self):
return self.obj
try:
embed_obj = json.loads(js_text)
except json.decoder.JSONDecodeError:
await ctx.send(':warning: **Invalid JSON data!**')
else:
sembed = SemiEmbed(embed_obj)
try:
await ctx.send(embed=sembed)
except discord.HTTPException as e:
if '400' in str(e):
await ctx.send(':warning: **Couldn\'t send embed, check your data!**')
else:
raise e
评论列表
文章目录