exports.run = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  if (issue.assignees && issue.assignees.find(assignee => assignee.login === commenter)) {
    return client.newComment(issue, repository, "**ERROR:** You have already claimed this issue.");
  }
  if (comment.author_association === "NONE" && !client.invites.get(commenter)) {
    exports.addCollaborator(client, comment, issue, repository);
  } else if (comment.author_association === "NONE") {
    const comment = client.templates.get("newContributor").replace("[commenter]", commenter)
    .replace("[repoName]", repoName).replace("[repoOwner]", repoOwner);
    client.newComment(issue, repository, comment);
  } else {
    exports.claimIssue(client, comment, issue, repository);
  }
};

exports.addCollaborator = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  if (!client.cfg.addCollabPermission) {
    const comment = "**ERROR:** `client.cfg.addCollabPermission` wasn't specified in `src/config.js`.";
    return client.newComment(issue, repository, comment);
  }
  client.repos.addCollaborator({
    owner: repoOwner, repo: repoName, username: commenter, permission: client.cfg.addCollabPermission
  }).then(() => {
    client.invites.set(commenter, `${repoOwner}/${repoName}#${issue.number}`);
    const comment = client.templates.get("newContributor").replace("[commenter]", commenter)
    .replace("[repoName]", repoName).replace("[repoOwner]", repoOwner);
    client.newComment(issue, repository, comment);
  });
};

exports.claimIssue = (client, comment, issue, repository) => {
  const commenter = comment.user.login;
  const issueNumber = issue.number;
  const repoName = repository.name;
  const repoOwner = repository.owner.login;
  client.issues.addAssigneesToIssue({
    owner: repoOwner, repo: repoName, number: issueNumber, assignees: [commenter]
  }).then((response) => {
    if (response.data.assignees) return;
    client.newComment(issue, repository, "**ERROR:** Issue claiming failed (no assignee was added).");
  });
};

exports.aliases = require("../config.js").claimCommands;
exports.args = false;

@@ -370,205 +370,461 @@
 %7D%0A  
-if (comment.author_association === %22NONE%22 && !client.invites.get(commenter)) %7B%0A    exports.addCollaborator(client, comment, issue, repository);%0A  %7D else if (comment.author_association === %22NONE%22) %7B
+client.repos.reviewUserPermissionLevel(%7B%0A    owner: repoOwner, repo: repoName, username: commenter%0A  %7D).then((response) =%3E %7B%0A    if (response.data.permission !== %22none%22) return exports.claimIssue(client, comment, issue, repository);%0A    if (!client.cfg.addCollabPermission) %7B%0A      const newComment = %22**ERROR:** %60client.cfg.addCollabPermission%60 wasn't specified in %60src/config.js%60.%22;%0A      return client.newComment(issue, repository, newComment);%0A    %7D
 %0A   
@@ -822,33 +822,36 @@
     %7D%0A    const 
-c
+newC
 omment = client.
@@ -1033,492 +1033,70 @@
 ry, 
-comment);%0A  %7D else %7B%0A    exports.claimIssue(client, comment, issue, repository);%0A  %7D%0A%7D;%0A%0Aexports.addCollaborator = (client, comment, issue, repository) =%3E %7B%0A  const commenter = comment.user.login;%0A  const repoName = repository.name;%0A  const repoOwner = repository.owner.login;%0A
+newComment);%0A  
   if (
-!
 client.
-cfg.addCollabPermission) %7B%0A    const comment = %22**ERROR:** %60client.cfg.addCollabPermission%60 wasn't specified in %60src/config.js%60.%22;%0A    return client.newComment(issue, repository, comment)
+invites.get(commenter)) return
 ;%0A  
-%7D%0A
   cl
@@ -1124,24 +1124,26 @@
 rator(%7B%0A    
+ 
+ 
 owner: repoO
@@ -1228,16 +1228,18 @@
 mission%0A
+  
   %7D).the
@@ -1248,24 +1248,26 @@
 () =%3E %7B%0A    
+ 
+ 
 client.invit
@@ -1337,217 +1337,9 @@
     
-const comment = client.templates.get(%22newContributor%22).replace(%22%5Bcommenter%5D%22, commenter)%0A    .replace(%22%5BrepoName%5D%22, repoName).replace(%22%5BrepoOwner%5D%22, repoOwner);%0A    client.newComment(issue, repository, comment
+%7D
 );%0A 

Check perm level i/o author association when assigning issues.