From fbccf8be24a91fa7c8da49257ca314c0f28f1273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Tue, 13 Jan 2026 17:08:31 +0800 Subject: [PATCH] Make emoji_likes_list optional in OB11Message Changed the OB11Message interface to make emoji_likes_list optional and updated GetMsg to initialize emoji_likes_list as an empty array before populating it. This prevents errors when the field is missing and improves type safety. --- packages/napcat-onebot/action/msg/GetMsg.ts | 4 ++-- packages/napcat-onebot/types/message.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/napcat-onebot/action/msg/GetMsg.ts b/packages/napcat-onebot/action/msg/GetMsg.ts index f791a403..a125ae62 100644 --- a/packages/napcat-onebot/action/msg/GetMsg.ts +++ b/packages/napcat-onebot/action/msg/GetMsg.ts @@ -35,10 +35,10 @@ class GetMsg extends OneBotAction { // } if (!msg) throw Error('消息不存在'); const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat); - if (!retMsg) throw Error('消息为空'); + retMsg.emoji_likes_list = []; msg.emojiLikesList?.map(emoji => { - retMsg.emoji_likes_list.push({ + retMsg.emoji_likes_list?.push({ emoji_id: emoji.emojiId, emoji_type: emoji.emojiType, likes_cnt: emoji.likesCnt, diff --git a/packages/napcat-onebot/types/message.ts b/packages/napcat-onebot/types/message.ts index 701468ce..46c06c94 100644 --- a/packages/napcat-onebot/types/message.ts +++ b/packages/napcat-onebot/types/message.ts @@ -31,7 +31,7 @@ export interface OB11Message { font: number; post_type?: EventType; raw?: RawMessage; - emoji_likes_list: Array<{ emoji_id: string; emoji_type: string; likes_cnt: string; }>;// 仅get_msg生效 + emoji_likes_list?: Array<{ emoji_id: string; emoji_type: string; likes_cnt: string; }>;// 仅get_msg生效 } // 合并转发消息接口定义