import { nextCursor, slackRequest } from './request.ts' import { boundedLimit, inputRecord, optionalBoolean, optionalString, requiredString } from './validation.ts' type RepliesResponse = { ok: boolean messages?: unknown[] has_more?: boolean response_metadata?: { next_cursor?: string } [key: string]: unknown } /** Read a Slack message thread available to the user. */ export default async function getReplies(params: Record) { const input = inputRecord(params) const result = await slackRequest('conversations.replies', { channel: requiredString(input, 'channel'), ts: requiredString(input, 'ts'), limit: boundedLimit(input.limit), cursor: optionalString(input, 'cursor'), oldest: optionalString(input, 'oldest'), latest: optionalString(input, 'latest'), inclusive: optionalBoolean(input, 'inclusive'), }) return { messages: result.messages ?? [], hasMore: result.has_more === true, nextCursor: nextCursor(result), } }