我目前正在为服务器开发自定义discord机器人。我正在(尝试)创建一个投票系统。因此,用户使用-poll yn poll question
。 yn部分描述了问题的类型,例如“是/否”。这是我到目前为止的内容:
@client.command()
async def poll(ctx, typee, *, msgg):
if typee=='yn':
msg = await ctx.channel.send("@everyone " + msgg)
reactions = ['a']
for emoji in reactions:
await client.add_reaction(msg, emoji)
await ctx.message.delete()
运行此程序时出现错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'add_reaction'
我正在使用重写和python 3.8.1
答案 0 :(得分:3)
add_reaction
方法是消息对象而不是客户端对象的一部分。您需要的是await msg.add_reaction(emoji)
而不是await client.add_reaction(msg, emoji)
如果您不知道'a'
不是有效的表情符号,则还有另一件事。
答案 1 :(得分:0)