import { WebClient } from "@slack/web-api"
/**
* List Channels
* List conversations by type — comma-separated public_channel, private_channel, mpim, im (default public_channel). Page with `cursor` = the previous `response_metadata.next_cursor`. Needs channels:read; private channels need groups:read, DMs im:read and group DMs mpim:read (user-token defaults; for a bot token tick them in the connect dialog). A bot sees only private channels and DMs it is in.
*/
export async function main(
auth: RT.Slack,
types?: string,
exclude_archived?: boolean,
limit?: number,
cursor?: string
) {
const client = new WebClient(auth.token)
return await client.conversations.list(
dropEmpty({ types, exclude_archived, 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 2 hours ago