* Update fields of the connected user's profile, e.g. { "display_name": "Ada", "pronouns": "she/her" }. Only the fields passed change; fields the workspace locks or does not show (often `title`) are ignored without an error, so check the returned profile. Custom profile fields go under "fields", keyed by field ID (from team.profile.get). An admin token on a paid plan can pass `user` to edit someone else. Requires a user token with users.profile:write.
6
*/
7
exportasyncfunctionmain(
8
auth: RT.Slack,
9
profile: { [key: string]: any },
10
user?: string
11
) {
12
const client = newWebClient(auth.token)
13
returnawait client.users.profile.set(dropEmpty({ profile, user }))
14
}
15
16
function dropEmpty<T extends { [key: string]: any }>(params: T) {
17
returnObject.fromEntries(
18
Object.entries(params).filter(
19
([, v]) => v !== undefined && v !== null && v !== ""