【发布时间】:2021-06-30 06:25:48
【问题描述】:
我希望我的 discord bod 在使用命令时从在线链接发送图像,而不是使用本地链接。我该怎么做?
【问题讨论】:
-
欢迎来到堆栈!你说的在线链接是什么意思?你试过什么吗?请查看How to ask a good question 并相应地编辑您的问题。
标签: python-3.x discord.py
我希望我的 discord bod 在使用命令时从在线链接发送图像,而不是使用本地链接。我该怎么做?
【问题讨论】:
标签: python-3.x discord.py
详细解释在FAQ of the docs
import io
import aiohttp
async with aiohttp.ClientSession() as session:
async with session.get(my_url) as resp:
if resp.status != 200:
return await channel.send('Could not download file...')
data = io.BytesIO(await resp.read())
await channel.send(file=discord.File(data, 'cool_image.png'))
【讨论】: