How do I get the bot to post Spoiler Images in discord.py?

耗尽温柔 提交于 2021-01-28 05:06:53

问题


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.

Thanks.


回答1:


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)


来源:https://stackoverflow.com/questions/60408884/how-do-i-get-the-bot-to-post-spoiler-images-in-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!