我如何让机器人在discord.py中发布Spoiler Images? [英] How do I get the bot to post Spoiler Images in discord.py?

查看:68
本文介绍了我如何让机器人在discord.py中发布Spoiler Images?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I started with discord.py a month or two ago, so this might just be really simple. My code is:

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

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

"archiver" is the channel I'm sending it in. How do I make it send with a spoiler tag? I looked through the docs but they're not helpful.

谢谢.

推荐答案

要以破坏者的身份上传图像,您需要在图像名称的开头添加 SPOILER _ 可以做到:

In order for you to upload an image as a spoiler, you need to add SPOILER_ to the start of the image name, you can do that with:

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

这篇关于我如何让机器人在discord.py中发布Spoiler Images?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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