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

标签 python-3.x discord.py

我想知道如何让我的机器人将嵌入的图像上传到 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/

相关文章:

python-3.x - 异步、等待和无限循环

python - 我的 TEMPMUTE 命令出现错误

python - 如何使用 discord.py 按 ID 删除特定消息

python - 将 matplotlib.pyplot 导入为 plt

python - 狮身人面像 : Link to a method of a class in another module in Python docstring

python - 使用 BeautifulSoup 获取 span 标签的值

python - 如何将 pandas 中的每周数据转换为每日数据?

python - 使用 Python 和 Keras 调整 CSV 数据的大小

python - 在 discord.py 中更改昵称会引发错误

python - 如何在一条不和谐消息中发送 for 循环的结果?