Command raised an exception: AttributeError: 'str' object has no attribute 'custom_emoji'

Command raised an exception: AttributeError: 'str' object has no attribute 'custom_emoji'

我正在尝试创建一个命令,将对特定消息做出反应的所有成员的姓名打印到我的控制台中。但是,它给我一个错误:

    @commands.command()
    async def whoreacted(self, ctx, message):
        for Member in discord.Reaction.users(message):
            memberlist = Member.name
            print(memberlist)
        await ctx.send('finished!')
  1. 您指的是 类 本身,而不是实例。 Here are the differences.
  2. message 参数将是一个字符串而不是 discord.Message 实例,您应该使用 MessageConverter 来获取它。
  3. 要获取对消息做出反应的用户,您需要使用嵌套循环

这是您的固定密码

@commands.command()
async def whoreacted(self, ctx, message: discord.Message):
    for reaction in message.reactions: # Iterating through every reaction
        async for user in reaction.users(): # Going through every member that reacted with that reaction
            print(user.name)

    await ctx.send('Finished')