简体   繁体   English

Discord bot 从用户消息中获取照片

[英]Discord bot get photo from user message

Heyyy I just was wondering how you can send an image to a channel and have the Discord bot add the image to a list of files it can send. Heyyy 我只是想知道如何将图像发送到频道并让 Discord 机器人将图像添加到它可以发送的文件列表中。

I want to make a.meme command where you can add photos via sending them and typing a command like !add-meme.我想制作一个.meme 命令,您可以在其中通过发送照片并输入类似 !add-meme 的命令来添加照片。 It will save the photo and display a random one when you send !meme它会保存照片并在您发送时随机显示一张!meme

Is this possible?这可能吗?

Yes, it's possible, but you would need an understanding of the discord py documents & a basic understanding of python.是的,这是可能的,但您需要了解 discord py 文档和对 python 的基本了解。

@client.command() 
async def readMessageURL(ctx):
    string = ctx.message.attachments[0]
    
 @client.command() 
    async def send(ctx):
      await TextChannel.send(file=discord.File('path/to/image.png')) #or
      await TextChannel.send(url=string))

Refrence:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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