简体   繁体   中英

How do I get the bot to post Spoiler Images in 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.

Thanks.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM