import { WebClient } from "@slack/web-api"
/**
* Update Message
* Replace the text and/or Block Kit blocks of a message identified by its channel and `ts`. A bot token can only edit the app's own messages, a user token only the user's own. Needs chat:write.
*/
export async function main(
auth: RT.Slack,
channel: string,
ts: string,
text?: string,
blocks?: { [key: string]: any }[]
) {
const client = new WebClient(auth.token)
return await client.chat.update(
dropEmpty({ channel, ts, text, blocks }) as any
)
}
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