Edits history of script submission #23050 for ' Update User Group Members (slack)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { WebClient } from "@slack/web-api"
    
    /**
     * Update User Group Members
     * Replace the full member list of a user group (e.g. @oncall) with the given user IDs — users not listed are removed. Workspace settings decide who may edit user groups; a bot token often gets permission_denied, so use a user token from someone allowed to. Requires usergroups:write on the connection.
     */
    export async function main(auth: RT.Slack, usergroup: string, users: string[]) {
      const client = new WebClient(auth.token)
      return await client.usergroups.users.update({
        usergroup,
        users: users.join(","),
      })
    }
    

    Submitted by hugo989 2 hours ago