gpt4 book ai didi

python-3.x - 上传嵌入图像?

转载 作者:行者123 更新时间:2023-12-03 09:35:45 28 4
gpt4 key购买 nike

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

最佳答案

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

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

要从您的 PC 发送文件,请在异步分支中使用 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)

关于python-3.x - 上传嵌入图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47515361/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com