title: GitHub API How to check if user has write access to a repository
body: <p>I currently have a bot which automates a few GitHub operations, like merging pull requests, notifying staff on Slack when a PR is opened, that kind of thing (it's a custom flavored Hubot instance)</p>
  
  <p>When staff give him the command to merge a pull request, he firstly checks to see if they belong to a team which has write access to that repository. It works, but the code isn't great.</p>
  
  <p>First he gets all teams on the organization, loops through them, gets all users assigned to that team, if he finds the user issuing the merge command, he then checks to see if that team has write access. If not does, authentication is good.</p>
  
  <p>Is this the best way to go about it? I feel like it could be much simpler.</p>