上传嵌入图片? [英] Upload an embed image?

查看:67
本文介绍了上传嵌入图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am wondering how I can make my bot upload an embedded image to a Discord channel. I know how to make it send embeds, but how do I upload an embedded image? Is it even possible with discord.py? Keep in mind I am not referring to the thumbnail image you can have in an embed image, I am wondering if you even can upload an embed image using Python. Thanks!

推荐答案

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

To send an image in an embed, use the set_image method of the embed:

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

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

To send a file from your PC, use the send_file method in async branch or the send method in rewrite branch.

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

# Rewrite
file = discord.File("filepath.png", filename="...")
await channel.send("content", file=file)

这篇关于上传嵌入图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆