0

Get User

by
Published today

Fetch one user's profile by ID.

Script slack Verified

The script

Submitted by hugo989 Bun
Verified 8 hours ago
1
import { WebClient } from "@slack/web-api"
2

3
/**
4
 * Get User
5
 * Fetch one user's profile by ID (e.g. U0123456789), such as the `user` on a message. Needs users:read, plus users:read.email for `profile.email`. Works with a bot or a user token.
6
 */
7
export async function main(
8
  auth: RT.Slack,
9
  user: string,
10
  include_locale?: boolean
11
) {
12
  const client = new WebClient(auth.token)
13
  return await client.users.info(
14
    include_locale === undefined ? { user } : { user, include_locale }
15
  )
16
}
17