G
G
Goshujin2021-06-01 12:44:59
Python
Goshujin, 2021-06-01 12:44:59

How to build Embed from JSON received in command?

Please help me repeat the command from the video, it is written in JS. I would like to port it to Python, but my knowledge of the language is not enough.
https://www.youtube.com/watch?v=gI8Gte8hPlE

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Endora Blackwell, 2021-06-12
@Goshujin

That's how you asked. If you have questions about the use - you can write in the comments

import json
from discord import Embed

def get_embed(json_):
    embed_json = json.loads(json_)

    embed = Embed().from_dict(embed_json)
    return embed

@bot.command(name = 'embed')
async def embed_send(ctx, channel: discord.TextChannel, *, args):
    embed = get_embed(args)
    
    if channel == "-":
        await ctx.send(embed = embed)
    else:
        await channel.send(embed = embed)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question