import { WebClient } from "@slack/web-api"
/**
* Create Channel
* Create a public or private channel. `name` must be lowercase, without spaces or periods, and at most 80 characters. Requires channels:manage (bot token) or channels:write (user token) on the connection; a private channel needs groups:write instead.
*/
export async function main(auth: RT.Slack, name: string, is_private?: boolean) {
const client = new WebClient(auth.token)
return await client.conversations.create(dropEmpty({ name, is_private }))
}
function dropEmpty<T extends { [key: string]: any }>(params: T) {
return Object.fromEntries(
Object.entries(params).filter(
([, v]) => v != null && v !== "" && !(Array.isArray(v) && v.length === 0)
)
) as T
}
Submitted by hugo989 9 days ago
import { WebClient } from "@slack/web-api"
/**
* Create Channel
* Create a public or private channel. `name` must be lowercase, without spaces or periods, and at most 80 characters. Requires channels:manage (bot token) or channels:write (user token) on the connection; a private channel needs groups:write instead.
*/
export async function main(auth: RT.Slack, name: string, is_private?: boolean) {
const client = new WebClient(auth.token)
return await client.conversations.create(dropEmpty({ name, is_private }))
}
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 21 days ago