-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to access thread_ts in message_replied
message event payloads
#796
Comments
Hi @SpencerKaiser , I know this may be a bit confusing but you can access the value via app.message("foo", async ({ message }) => {
if (message.subtype === "message_replied") {
message.message.thread_ts
}
});
app.message("foo", async ({ event }) => {
if (event.subtype === "message_replied") {
event.message.thread_ts
}
}); |
message_replied
subtype types are brokenmessage_replied
message event payloads
@seratch thanks for the super quick response!! I actually tried that earlier and had a similar problem... I know that value is there, but I can't seem to make any progress on getting it out safely:
import { App, Middleware } from '@slack/bolt';
export type AppMiddlewareFunction<Args> = (app: App) => Middleware<Args>;
export const messageReplied: AppMiddlewareFunction<SlackEventMiddlewareArgs<'message'>> = (app: App) => async ({
message,
event,
}) => {
console.log(message.message);
// Property 'message' does not exist on type 'MessageEvent'.
// Property 'message' does not exist on type 'GenericMessageEvent'.
console.log(message.thread_ts);
// Property 'thread_ts' does not exist on type 'MessageEvent'.
// Property 'thread_ts' does not exist on type 'EKMAccessDeniedMessageEvent'.
console.log(event.message);
// Property 'message' does not exist on type 'MessageEvent'.
// Property 'message' does not exist on type 'GenericMessageEvent'.
console.log(message.thread_ts);
// Property 'thread_ts' does not exist on type 'MessageEvent'.
// Property 'thread_ts' does not exist on type 'EKMAccessDeniedMessageEvent'.
}; I know that pattern might look a little strange, but it was the best thing my team and I could figure out to make the handlers easily testable (which they really are!!). Any idea what the issue is there? |
@SpencerKaiser interestingly (it's a TypeScript compiler's magic), having if statement makes the value's type compatible with "message_replied" events. |
I think the issue on my end is that Are you (or is someone else from your team) a Types guru that might now what's going on there? |
Thus, the type provides only the fields available for all the possible types. And then, once you tell the If this library provides type parameter like the one for app.action({"action_id": "aid", "type": "block_actions"}, async ({ action, ack }) => {
action // this is compatible with `block_actions` payload
}); The following code may work. app.message({"pattern": "foo", "subtype": "message_replied"}, async ({ message }) => {
message.message.thread_ts // this compiles
}); |
Setting that subtype to |
Description
Describe your issue here.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: ^3.2.0
node version: ^14
Expected result:
thread_ts
will be available formessage
sActual result:
Compiler error
Code
Property 'thread_ts' does not exist on type 'MessageEvent'.
The text was updated successfully, but these errors were encountered: