不一致机器人向消息discord.py添加反应(无自定义表情符号) [英] Discord bot adding reactions to a message discord.py (no custom emojis)

查看:33
本文介绍了不一致机器人向消息discord.py添加反应(无自定义表情符号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图让一个使用discord.py的机器人在阅读this后使用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上的任何其他相关问题对此都没有帮助 您对如何实现这一点有什么想法

推荐答案

错误消息告诉您错误是什么:message argument must be a Message<&q;

在行中

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)

请注意,在更高版本的discord.py中,add_reaction已从bot.add_reaction(msg, emoji)更改为await msg.add_reaction(emoji)

这篇关于不一致机器人向消息discord.py添加反应(无自定义表情符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆