Answer the question
In order to leave comments, you need to log in
How to build an Embed from JSON data?
I'm trying to make a command that will accept JSON data, and build Embed from them.
Let's say a person sends a string like this:
{"plainText": "Testing", "fields": [{"name": "Test-1", "value": "Value-1", "inline": false}, {"name": "Test-2", "value": "Value-2", "inline": true}], "color": 0}
emb = discord.Embed(color = 0x00000)
emb.add_field(name = "Test-1", value = "Value-1", inline = False)
emb.add_field(name = "Test-2", value = "Value-2", inline = True)
await ctx.send(plainText, embed = emb)
Answer the question
In order to leave comments, you need to log in
Use the method from_dict()
Read more here
emb_json = json.load(embed_file)
emb = discord.Embed.from_dict(emb_json)
await ctx.send(embed=emb)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question