上传嵌入图片?

问题描述 投票:3回答:1

我想知道如何让我的机器人上传嵌入图像成为Discord频道。我知道如何让它发送嵌入消息,但我如何上传嵌入图像?甚至可以使用discord.py吗?请记住,我不是指嵌入图像中可以包含的缩略图,我想知道您是否可以使用Python上传嵌入图像。谢谢!

python-3.x discord.py
1个回答
8
投票

要在嵌入中发送图像,请使用嵌入的set_image方法:

e = discord.Embed()
e.set_image(url="https://discordapp.com/assets/e4923594e694a21542a489471ecffa50.svg")

要从PC发送文件,请在async分支中使用send_file方法,或在重写分支中使用send方法。

# Async
await bot.send_file(channel, "filepath.png", content="...", filename="...")

# Rewrite
file = discord.File("filepath.png", filename="...")
await channel.send("content", file=file)
© www.soinside.com 2019 - 2024. All rights reserved.