用嵌入文件(Discord.py)回复消息

用嵌入文件(Discord.py)回复消息,discord.py,Discord.py,我遇到了一个问题,无法用嵌入的邮件回复邮件。 这可能吗?我猜是的,我只是做错了 My error-TypeError:对象方法不能用于'await'表达式 if message.content.startswith('!test'): await message.reply embedVar = discord.Embed(description=".order", color=0x7289da) embedVar.ad

我遇到了一个问题,无法用嵌入的邮件回复邮件。 这可能吗?我猜是的,我只是做错了

My error-TypeError:对象方法不能用于'await'表达式

if message.content.startswith('!test'):
       await message.reply
       embedVar = discord.Embed(description=".order", color=0x7289da)       
       embedVar.add_field(name='test', value='test')
       await message.channel.send(embed=embedVar)
您没有正确使用该函数。您不能像对待
等待消息那样单独使用它。请在代码中回复

#在"消息事件"上,以您的方式完成
如果message.content.startswith(“!test”):
等待消息。回复(“这是一个测试!”)
#或者如果您更喜欢命令扩展(推荐)
@bot.command()
异步def测试(ctx):
等待ctx。回复(“这是一个测试!”)
#你也可以让它不提及作者
等待ctx.reply(“这是一个测试!”,提及作者=False)
#请注意,命令示例中的两个代码都可以用于on_消息事件
#只要您记得将ctx更改为message
上面的代码已经过测试,如下图所示


至于回复嵌入,我发现如果bot只回复嵌入,它可能不会提到作者

embed=discord.embed(description=“这是一个测试”,color=0x123456)
等待消息。回复(嵌入=嵌入)
上述代码的工作原理如下图所示

看一下,这应该是可能的。请注意,这是一个方法,而不是一个属性。文档描述了该方法:

一种快捷方式,可通过
abc.Messageable.send()
回复邮件

该方法采用位置参数
content
和关键字参数
kwargs
,它们对应于该方法的关键字参数。由于
embed
是关键字参数之一,因此它也是
reply()
的参数之一

if message.content.startswith(“!test”):
嵌入=discord.embed(description=“.order”,color=0x7289da)
嵌入.添加字段(name=“test”,value=“test”)
等待消息。回复(嵌入)
另一方面,我建议使用
discord.ext.commands
框架,而不是使用
On_message()
和string方法。

尝试以下方法:

嵌入=discord.embed(title=“Tile”

`

description="Desc", color=0x00ff00) 

embed.add_field(name="Fiel1", value="hi", inline=False)

embed.add_field(name="Field2", value="hi2", inline=False)
await self.bot.say(embed=embed)