Discord bot向消息Discord.py添加响应(无自定义表情符号)

2024-09-28 20:57:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直试图让一个机器人使用discord.py在阅读this(这不是我想要的,因为我没有使用自定义的emojis)之后,使用discord.py添加对消息的响应,但它最终给出了这个错误:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: message argument must be a Message

我试过这个密码

@commands.command(pass_context=True)
async def emoji(ctx):
    msg = "working"
    await bot.say(msg)
    reactions = ['dart']
    for emoji in reactions: await bot.add_reaction(msg, emoji)

这里关于discord.py的任何其他相关问题对此都没有帮助 关于如何实现这一点的任何想法


Tags: py消息bot错误机器人msgawaitthis
1条回答
网友
1楼 · 发布于 2024-09-28 20:57:04

错误消息告诉您错误是什么:“message argument must be a Message

排队

await bot.add_reaction(msg, emoji)

msg是字符串,而不是Message对象。您需要捕获发送的消息,然后将响应添加到该消息:

@commands.command(pass_context=True)
async def emoji(ctx):
    msg = await bot.say("working")
    reactions = ['dart']
    for emoji in reactions: 
        await bot.add_reaction(msg, emoji)

相关问题 更多 >