2024-10-01 07:47:57 发布
网友
await ctx.send(file=discord.File(r'www.abc.com/wal1.jpg') 这样不行
await ctx.send(file=discord.File(r'www.abc.com/wal1.jpg')
在不一致情况下,指向文件的链接将自动转换为该文件,因此您应该避免:
await ctx.send("www.abc.com/wal1.jpg")
如果您确实想发送文件,可以下载它,然后使用discord.File()方法发送。大概是这样的:
discord.File()
response = requests.get("www.abc.com/wal1.jpg") with open(f"img.jpg", "wb") as file: file.write(response.content) await ctx.send(file=discord.File("img.jpg"))
在不一致情况下,指向文件的链接将自动转换为该文件,因此您应该避免:
如果您确实想发送文件,可以下载它,然后使用
discord.File()
方法发送。大概是这样的:相关问题 更多 >
编程相关推荐