首页 > 解决方案 > 如何让机器人在 discord.py 中发布剧透图像?

问题描述

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

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

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

谢谢。

标签: pythondiscord.py

解决方案


为了让您上传图片作为剧透,您需要添加SPOILER_到图片名称的开头,您可以这样做:

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

推荐阅读