Skip to content

Fix: Change faceId type from number to number | string in setMsgReaction#534

Merged
sj817 merged 2 commits into
mainfrom
copilot/fix-d7ee752c-a695-4404-99ff-dd139640c8b0
Oct 2, 2025
Merged

Fix: Change faceId type from number to number | string in setMsgReaction#534
sj817 merged 2 commits into
mainfrom
copilot/fix-d7ee752c-a695-4404-99ff-dd139640c8b0

Conversation

Copilot AI commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Description

Fixed the faceId parameter type in bot.setMsgReaction to accept both number and string types, resolving a type incompatibility issue between the adapter base class and specific adapter implementations.

Problem

The setMsgReaction method was defined with faceId as number only, but adapter implementations (like Lagrange.OneBot and NapCat.Onebot) require string types for their underlying APIs. This created a type mismatch where:

  • Other adapters have faceId as string-only type
  • The base class type signature was too restrictive
  • The actual implementation was already converting numbers to strings (faceId + '')

Solution

Updated the type signature across all adapter classes to accept faceId: number | string:

  1. Interface definition (packages/core/src/types/adapter/class.ts) - Updated the AdapterType interface
  2. Base adapter (packages/core/src/adapter/base/index.ts) - Updated the abstract base implementation
  3. OneBot adapter (packages/core/src/adapter/onebot/core/core.ts) - Updated the concrete implementation
  4. Console adapter (packages/core/src/adapter/input/index.ts) - Updated the console implementation

This change is backward compatible since it expands the accepted types rather than restricting them, and the existing string conversion logic (faceId + '') already handles both number and string inputs correctly.

Testing

Verified that the type change is valid TypeScript and that the existing implementation logic (which converts to string) works correctly with both input types.

Fixes issue where faceId type was incompatible with adapter base class requirements.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: node /home/REDACTED/.npm/_npx/4876f32048baf8ac/node_modules/.bin/prebuild-install -r napi --pkg_version=5.1.7 --pkg_name=sqlite3 (dns block)
    • Triggering command: node /home/REDACTED/.npm/_npx/c65dbefa27d408e0/node_modules/.bin/prebuild-install -r node --pkg_version=0.12.0 --pkg_name=node-pty-prebuilt-multiarch (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: bot.setMsgReaction 的 faceId 类型不应该只是 number</issue_title>
<issue_description>### 描述问题

其他适配器的faceId有且只有string类型,类型无法和适配器基类完美兼容

复现步骤

  1. 第一步
  2. 第二步
  3. ...

预期行为

number | string

实际行为

number

操作系统

any

Node.js 版本

any

项目版本

1.10.18

附加信息

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #506

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Bug: bot.setMsgReaction 的 faceId 类型不应该只是 number Fix: Change faceId type from number to number | string in setMsgReaction Oct 2, 2025
Copilot AI requested a review from sj817 October 2, 2025 00:04
@ikenxuan

ikenxuan commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator

怎么变得这么智能了,好厉害

@sj817

sj817 commented Oct 2, 2025

Copy link
Copy Markdown
Member

@yusheng929 karin-plugin-adapter-icqq 需要同步修改此接口类型

@github-actions

github-actions Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

你可以通过以下命令安装该版本:

pnpm add https://pkg.pr.new/node-karin@dc395ee -w

@sj817
sj817 marked this pull request as ready for review October 2, 2025 01:02
Copilot AI review requested due to automatic review settings October 2, 2025 01:02
@sj817
sj817 merged commit 5233508 into main Oct 2, 2025
4 checks passed
@sj817
sj817 deleted the copilot/fix-d7ee752c-a695-4404-99ff-dd139640c8b0 branch October 2, 2025 01:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a type incompatibility issue in the setMsgReaction method by changing the faceId parameter type from number to number | string across all adapter implementations.

  • Updated type signature to accept both number and string for faceId parameter
  • Applied the change consistently across interface definition, base class, and concrete implementations
  • Maintains backward compatibility while resolving type mismatches with specific adapter implementations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/core/src/types/adapter/class.ts Updated interface definition to accept number | string for faceId
packages/core/src/adapter/base/index.ts Updated abstract base class method signature
packages/core/src/adapter/onebot/core/core.ts Updated OneBot adapter implementation
packages/core/src/adapter/input/index.ts Updated console adapter implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions Bot mentioned this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: bot.setMsgReaction 的 faceId 类型不应该只是 number

4 participants