import { WebClient } from "@slack/web-api"
/**
* Get Thread Replies
* Fetch a thread: the parent message first, then its replies, oldest first. `ts` is the parent message's timestamp. A bot token (channels:history) can read threads in public channels the app is in. Threads in private channels, DMs and group DMs need a user token with groups:history, im:history or mpim:history. Paginate with `response_metadata.next_cursor`.
*/
export async function main(
auth: RT.Slack,
channel: string,
ts: string,
oldest?: string,
latest?: string,
inclusive?: boolean,
limit?: number,
cursor?: string
) {
const client = new WebClient(auth.token)
return await client.conversations.replies(
dropEmpty({ channel, ts, oldest, latest, inclusive, limit, cursor })
)
}
function dropEmpty<T extends { [key: string]: any }>(params: T) {
return Object.fromEntries(
Object.entries(params).filter(
([, v]) => v !== undefined && v !== null && v !== ""
)
) as T
}
Submitted by hugo989 1 hour ago