code: async function userHasRole (robot, user, role) {
    try {
      robot.logger.info(`[userHasRole] checking if ${user.name} has ${role} role`)
      const info = await robot.adapter.api.get('users.info', { username: user.name })
      if (!info.user) throw new Error('No user data returned')
      if (!info.user.roles) throw new Error('User data did not include roles')
      return (info.user.roles.indexOf(role) !== -1)
    } catch (err) {
      robot.logger.error('Could not get user data with bot, ensure it has `view-full-other-user-info` permission', err)
    }
  }
docs: Use API to check if role exists on given user.
  Bot requires `view-full-other-user-info` permission.
  Test with `node docs/snippets userHasRole` from project room.
  @param {Robot} robot        Hubot instance
  @param {User} user          Hubot user object containing name
  @param {string} role        Role to check for in roles array
  @return {boolean|undefined} If user has the role