【问题标题】:Green to python, having issues with Discord EmbedGreen to python,Discord Embed 有问题
【发布时间】:2020-11-27 07:43:40
【问题描述】:

所以不断收到类型错误,说明 send() 得到了意外的关键字参数“嵌入” 我不确定我做错了什么。任何帮助都会很棒。

client = discord.Client()

@client.event
async def on_message(message):
    if message.content == 'what is the version':
        dev_channel = client.get_channel(Deleted for obs reasons)

        myEmbed = discord.Embed(title="Current Version", description="The bot 
        is in Version 1.0", color=0x00ff00)
        
        myEmbed.add_field(name="Version Code:", value="v1.0.0", inline=False)
        
        myEmbed.add_field(name="Date Released:", value="November 25th, 2020", 
        inline=False)

        myEmbed.set_footer(text="End of message")

        await dev_channel.send(Embed=myEmbed)

当我在不和谐的文本通道中输入版本时,Visual Studios 在终端中提供以下文本。

Ignoring exception in on_message
Traceback (most recent call last):                                                               
", line 333, in _run_event
File "C:\Users\lazy5\AppData\Local\Programs\Python\Python39\lib\site- 
packages\discord\client.pyy", line 333, in _run_event
await coro(*args, **kwargs)
File "c:\Users\lazy5\Desktop\worth.py", line 30, in on_message
await dev_channel.send(Embed=myEmbed)
TypeError: send() got an unexpected keyword argument 'Embed'

【问题讨论】:

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


    【解决方案1】:

    在您的发送线路上

    await dev_channel.send(Embed=myEmbed)
    

    'Embed=' 应该像这样小写:

    await dev_channel.send(embed=myEmbed)
    

    【讨论】:

    • 我也改了,没改。我觉得好像它没有从 discord 中获取嵌入模块。
    • @RWT98 我已经用修复测试了你的代码。你能把修改后的代码发过来吗?
    • 所以我尝试了很多东西来尝试自己解决这个问题,但是这里没有运气是我得到的错误的屏幕截图。该机器人上线并将一直在线,直到我在聊天中输入“版本是什么”。我开始认为某些东西没有正确安装? imgur.com/a/ettcTUH 感谢您抽出宝贵时间提供帮助。
    • @RWT98 答案仍然是正确的。您更改了代码。将第 11 行 embed 上的 'e' 大写,然后再次运行。
    • 感谢所有帮助。我最终发现这是问题所在,但不久之后导入熊猫开始遇到更多问题。我最终从 3.9 切换到 3.8,从那以后一直很顺利。再次感谢您抽出宝贵时间提供帮助!
    猜你喜欢
    • 2018-03-09
    • 1970-01-01
    • 2019-03-29
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    相关资源
    最近更新 更多