表情表态对象

在消息、帖子、评论、回复中使用的表情。

表情表态相关事件可参考表情表态事件

事件监听方式可参考ws 使用

具体示例可参考使用示例

MessageReaction

字段名类型描述
user_idstring用户 ID
guild_idstring频道 ID
channel_idstring子频道 ID
targetReactionTarget表态对象
emojiEmoji表态所用表情

ReactionTarget

字段名类型描述
idstring表态对象 ID
typenumber表态对象类型,参考 ReactionTargetType

ReactionUsers

字段名类型描述
usersUser 对象列表用户对象列表,参考 User,会返回 id, username, avatar 等
cookiestring分页参数,用于拉取下一页
is_endbool是否已拉取完成到最后一页,true代表完成

ReactionTargetType

描述
0消息
1帖子
2评论
3回复

表情表态事件监听

代码示例

from typing import List

import botpy

from botpy.message import Message
from botpy.types import reaction
from botpy.types.user import User

class MyClient(botpy.Client):
    async def on_at_message_create(self, message: Message):
        users: List[User] = []
        cookie = ""
        while True:
            reactionUsers: reaction.ReactionUsers = await self.api.get_reaction_users(
                "2568610",
                "088de19cbeb883e7e97110a2e39c0138d80d48acfc879406",
                1,
                "4",
                cookie=cookie,
            )

            if not reactionUsers:
                break

            users.extend(reactionUsers["users"])

            if reactionUsers["is_end"]:
                break
            else:
                cookie = reactionUsers["cookie"]

        print(len(users))
        for user in users:
            print(user["username"])

intents = botpy.Intents(public_guild_messages=True)
client = MyClient(intents)
client.run(appid={appid}, token={token})

在频道内,长按某条消息进行表情回复 👍,ws 收到消息并打印如下 log 信息:

"event MESSAGE_REACTION_ADD, reaction channel id 2568610"