liatrio/gratibot

View on GitHub
service/apiwrappers.js

Summary

Maintainability
A
0 mins
Test Coverage
B
83%
const { SlackError } = require("./errors");

async function userInfo(client, userId) {
  const response = await client.users.info({ user: userId });
  if (response.ok) {
    return response.user;
  }

  throw new SlackError(
    "users.info",
    response.error,
    `Something went wrong while sending recognition. When retreiving user information from Slack, the API responded with the following error: ${response.message} \n Recognition has not been sent.`,
  );
}

module.exports = {
  userInfo,
};