Skip to content

Commit

Permalink
Allow permissioned ambassadors to add leaders to clubs
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewStanciu authored and maxwofford committed Jan 18, 2020
1 parent 1a4f927 commit 18cd324
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/interactions/leaderAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const interactionLeaderAdd = (bot, message) => {
return
}

if (!commandUser.club) {
if (!(commandUser.club && commandUser.ambassador)) {
console.log(`${commandUser.user} doesn't have a club`)
bot.replyPrivateDelayed(message, transcript('leaderAdd.invalidClub'))
return
Expand Down
19 changes: 14 additions & 5 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const airPatch = (baseName, recordID, values, options = {}) =>
}
console.log(
`Airtable updated my ${baseName} record from ${timestamp} in ${Date.now() -
timestamp}ms`
timestamp}ms`
)
resolve(record)
})
Expand All @@ -69,7 +69,7 @@ export const airCreate = (baseName, fields, options = {}) =>
}
console.log(
`Airtable saved my ${baseName} record from ${timestamp} in ${Date.now() -
timestamp}ms`
timestamp}ms`
)
resolve(record)
})
Expand Down Expand Up @@ -134,7 +134,7 @@ export const airGet = (
}
console.log(
`AirTable got back to me from my question at ${timestamp} with ${
data.length
data.length
} records. The query took ${Date.now() - timestamp}ms`
)
resolve(data)
Expand Down Expand Up @@ -251,6 +251,15 @@ export const getInfoForUser = user =>
airFind('People', 'Slack ID', user).then(
person => (results.person = person)
),
airFind('Ambassadors', 'Slack ID', user).then(
() => {
airGet('Ambassadors', 'IF(Permissioned = 1, "true", "false"').then(
permissionedAmbassador => {
results.permissionedAmbassador = permissionedAmbassador
}
)
}
)
])
.then(async () => {
if (!results.person && results.slackUser) {
Expand Down Expand Up @@ -316,7 +325,7 @@ export const getInfoForUser = user =>
.then(() => {
console.log(
`Finished pulling up the info about user '${user}' from ${timestamp} in ${Date.now() -
timestamp}ms`
timestamp}ms`
)
resolve(results)
})
Expand Down Expand Up @@ -504,7 +513,7 @@ export const transcript = (search, vars) => {
return evalTranscript(recurseTranscript(searchArr, transcriptObj), vars)
}
const evalTranscript = (target, vars = {}) =>
function() {
function () {
return eval('`' + target + '`')
}.call({
...vars,
Expand Down

0 comments on commit 18cd324

Please sign in to comment.