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

时间:2021-04-26 14:50:14

标签: python image discord

嘿嘿 我只是想知道如何将图像发送到频道并让 Discord 机器人将图像添加到它可以发送的文件列表中。

我想创建一个 !meme 命令,您可以在其中通过发送照片并输入诸如 !add-meme 之类的命令来添加照片。它会保存照片并在您发送时随机显示一张!meme

这可能吗?

1 个答案:

答案 0 :(得分:0)

是的,这是可能的,但是您需要了解 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))

参考: