如何让机器人在discord.py中发布Spoiler图片?

时间:2020-02-26 07:34:19

标签: python discord.py

我在一两个月前从discord.py开始,所以这可能真的很简单。 我的代码是:

    attachment_url = ctx.message.attachments[0].url
    await archiver.send(attachment_url)

“存档”是我要发送的频道。 如何使它带有扰流标签发送?我浏览了文档,但它们没有帮助。

谢谢。

1 个答案:

答案 0 :(得分:1)

要让您以破坏者的身份上传图像,您需要在图像名称的开头添加SPOILER_,您可以使用以下方法进行操作:

file = ctx.message.attachments[0]
file.filename = f"SPOILER_{file.filename}"
spoiler = await file.to_file()
await archiver.send(file=spoiler)