【发布时间】:2020-11-11 05:42:06
【问题描述】:
基本上,我试图将所有对某条消息做出反应的人收集到一个列表中,这样我就可以看到谁参加了活动。我知道我可以看看每个手动做出反应的人,但我想稍后在有时间时对此进行扩展。
我的计划是添加 2 个单独的命令,一个是启动反应的命令,另一个是说明所有做出反应的人(列表)。但到目前为止,我只是坚持使用这个不起作用的单个命令。关于如何将其改造成 2 个命令的任何提示?
无论如何,到目前为止我有这个。
@client.command(pass_context = True)
async def react(ctx):
msg = await ctx.send('React to this if you will be free for the event!')
await msg.add_reaction("✅")
await asyncio.sleep(5)
cache_msg = discord.utils.get(client.messages, id = msg.id)
for reactor in cache_msg.reactions:
reactors = await client.get_reaction_users(reactor)
for member in reactors:
await ctx.send(member.name)
完整的追溯:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'messages'
【问题讨论】:
-
该错误涉及
Bot对象,能否请您分享该对象的代码?
标签: python discord discord.py