Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

discord.py - How do you create a discord bot that creates embeds which contain previews of videos

I'm creating a bot that allows users to create embedded messages. Here is a command that I am working with:

    @bot.command()
async def embed(ctx,title_str,text_str,url_str):
    embed=discord.Embed(title=title_str, url=url_str, description=text_str, color=0xFF5733)
    await ctx.send(embed=embed)

This works fine, but if a video is linked I'd like it to add a preview image - in the same way it does if you post a Youtube link I tried adding image = video_url to the discord.Embed command, but this did not help.

Clearly discord is able to do this because when you type in a url to a video you get a preview in an embed automatically generated.

question from:https://stackoverflow.com/questions/65830723/how-do-you-create-a-discord-bot-that-creates-embeds-which-contain-previews-of-vi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Per the Discord API docs: "For the embed object, you can set every field except type (it will be rich regardless of if you try to set it), provider, video, and any height, width, or proxy_url values for images."

Therefore, you cannot assign a video to Embeds via the API.

See: https://discord.com/developers/docs/resources/channel#create-message


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...