【问题标题】:How to interact with attached image in discord.py如何与 discord.py 中的附加图像进行交互
【发布时间】:2019-12-27 00:03:59
【问题描述】:

我希望我的机器人与附加到它的消息的图像进行交互。它将获取图像并将其存储到自己。这样的代码怎么写?

这里是当前代码的一部分:

@bot.command()
async def hello(ctx):
    await ctx.send(embeds)

仅此而已,我希望你能帮助我

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您可以像这样重新发送图像:

    @bot.command()
    async def hello(ctx):
        files = []
        for file in ctx.message.attachments:
            fp = BytesIO()
            await file.save(fp)
            files.append(discord.File(fp, filename=file.filename, spoiler=file.is_spoiler()))
        await ctx.send(files=files)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-05
      • 2015-11-19
      • 2018-09-20
      相关资源
      最近更新 更多