简体   繁体   中英

DISCORD.PY - Bot bot sends image as spoiler

I'm trying to get my bot to send an image as a spoiler, but I'm not having success. The image comes from a URL, but how do I mark it as a spoiler?

my code:

@client.command()
async def ordema(archiver): #command
    await archiver.send(f'https://imageproxy.ifunny.co/crop:x-20,resize:640x,quality:90x75/images/a475315bd258dc83078c79ea338a0118919944fbecdc8b1bb5d4bda5d3dbab53_1.jpg') #image url

As said in my comment:

Discord supports the addition of SPOILER_ to images. Your code could look something like this:

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