From 7bb57cd78a38fee9cd5304e9c9e7ea8e93439c88 Mon Sep 17 00:00:00 2001 From: "Wesley F. Young" Date: Mon, 26 Aug 2024 12:38:39 +0800 Subject: [PATCH] fix: use `allSettled` instead of `all` when parsing raw message --- src/onebot/api/msg.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index b15843bc..6c3abc13 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -707,7 +707,7 @@ export class OneBotMsgApi { } } - const msgSegments = (await Promise.all(msg.elements.map( + const msgSegments = (await Promise.allSettled(msg.elements.map( async (element) => { for (const key in element) { if (keyCanBeParsed(key, this.rawToOb11Converters) && element[key]) { @@ -721,7 +721,14 @@ export class OneBotMsgApi { } } } - ))).filter(entry => !!entry); + ))).filter(entry => { + if (entry.status === 'fulfilled') { + return !!entry.value; + } else { + this.core.context.logger.logError('消息段解析失败', entry.reason); + return false; + } + }).map((entry) => (>entry).value); const msgAsCQCode = msgSegments.map(msg => encodeCQCode(msg)).join('').trim();