ThreadBroadcastMessageEvent is missing `bot_id`

未关闭 适合新手
#2,766 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sean0407 已经在做这个了。

开始于 2026年10月13日。

  • #2769 来自 @sean0407 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
api

调研方向

该 issue 指向 packages/types/src/events/message.ts,具体是第 276–300 行附近的 ThreadBroadcastMessageEvent 定义。将该类型与 GenericMessageEvent 一起阅读,并检查是否有相关的类型测试。当广播事件上表示了 bot_id?: string,且类型接受访问 event.bot_id 时,即为完成。

由索引模型根据 Issue 内容生成。

描述

untriaged
Package

@slack/types

SDK Version

@slack/[email protected]

Node.js Version

N/A (type definition issue)

Operating System

No response

Steps to Reproduce
  1. Set up an app subscribed to the message.channels event.
  2. Start a thread as a user in a channel where the app is a member.
  3. As the bot, reply in that thread with chat.postMessage({ channel, thread_ts, text, reply_broadcast: true }).
  4. Inspect the payload of the message event the app receives for that reply.

In TypeScript, the following code does not compile:

import type { ThreadBroadcastMessageEvent } from "@slack/types";

function isFromBot(event: ThreadBroadcastMessageEvent) {
  return !!event.bot_id; // error TS2339: Property 'bot_id' does not exist on type 'ThreadBroadcastMessageEvent'
}
Expected Result

ThreadBroadcastMessageEvent defines bot_id?: string, like GenericMessageEvent does. Slack sends this field, so we can check whether the broadcast reply itself was posted by a bot without a type assertion.

Actual Result

Slack sends a message event with subtype: "thread_broadcast". The event includes a top-level bot_id:

{
  "type": "message",
  "subtype": "thread_broadcast",
  "user": "U0XXXXXXX",
  "bot_id": "B0XXXXXXX",
  "app_id": "A0XXXXXXX",
  "text": "broadcast test",
  "ts": "1791786680.944589",
  "thread_ts": "1791786656.190749",
  "channel": "C0XXXXXXX",
  "channel_type": "channel",
  "event_ts": "1791786680.944589",
  "root": { "user": "U0YYYYYYY", "ts": "1791786656.190749", "reply_count": 2, ... },
  "blocks": [ ... ]
}

However, ThreadBroadcastMessageEvent does not define bot_id, even after #2763:

https://github.com/slackapi/node-slack-sdk/blob/e02e7feeb500bfde1f947401a639633e42ce2f91/packages/types/src/events/message.ts#L276-L300

The only bot_id reachable from this type is root.bot_id, which describes the thread parent, not the broadcast reply. Code that uses root.bot_id to detect bot messages gets both cases wrong: a user's broadcast in a bot-started thread looks like a bot message, and a bot's broadcast in a user-started thread looks like a user message.

This is a follow-up to #2762, which covered other missing fields on the same type.

主要语言
TypeScript
星标
3.4k
派生
691
平均合并
2 天 20 小时
30 天内合并 PR
25

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

slackapi/node-slack-sdk 的其他 Issue

查看 slackapi/node-slack-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。