【问题标题】:Is there any way to send embed pictures through a command?有没有办法通过命令发送嵌入图片?
【发布时间】:2019-02-16 02:50:57
【问题描述】:

所以我已经在这个机器人上工作了一段时间,但我无法让它通过命令发送嵌入图片。如果有人可以帮助我,我将非常感激。这是代码:

if message.content.upper().startswith('!PNG'):
    role = get(message.server.roles, id="517064875134943262")
    userID = message.author.id
    e = discord.Embed()
    e.set_image(url="https://i.imgur.com/5nqpFiF.jpg")
    if not "343249790047485952" in [role.id for role in message.author.roles]:
        await client.send_message(message.channel, 'Insufficient Permissions.')
    else:
        await client.send_message(message.channel, e)

这就是我在 Discord 上得到的:

discord.embeds.Embed 对象位于 0x000000010377EEE

【问题讨论】:

    标签: python python-3.x discord.py


    【解决方案1】:

    您需要使用 embed 关键字参数传递嵌入,否则您将发送其字符串表示形式。

    await client.send_message(message.channel, embed=e)
    

    您可以查看Client.send_message 文档了解更多详细信息。

    【讨论】:

    • 非常感谢。这有帮助:D
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    • 2017-09-28
    • 2011-06-09
    • 1970-01-01
    相关资源
    最近更新 更多