当机器人响应我输入的斜杠命令时,我在尝试向机器人的响应中添加 react 时遇到问题。
@bot.slash_command(name='test', description="Test.")
async def test(ctx):
msg = await ctx.send("Hello.")
await msg.add_reaction('🤖')
正如您所看到的,它应该添加对其自己的消息的 react 。 但我收到这个错误:
nextcord.errors.ApplicationInvokeError:命令引发异常:AttributeError:“PartialInteractionMessage”对象没有属性“add_reaction”
请告诉我如何向斜杠命令添加 react 。
最佳答案
说明
根据错误,ctx.send
返回 PartialInteractionMessage
。来自 the docs :
This does not support most attributes and methods of
nextcord.Message
. Thefetch()
method can be used to retrieve the fullInteractionMessage
object.
代码
@bot.slash_command(name='test', description="Test.")
async def test(ctx):
msg = await ctx.send("Hello.")
full_msg = await msg.fetch()
await full_msg.add_reaction('🤖')
关于discord.py - 如何为斜杠命令的响应添加 react ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73110608/