From e90ecbe38fd75392d739c655e792365902e664a6 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Tue, 24 Sep 2019 13:45:02 -0400 Subject: [PATCH] Fix /leader-add usage in uninvited channels --- src/interactions/leaderAdd.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/interactions/leaderAdd.js b/src/interactions/leaderAdd.js index 068add4e..57cc5d51 100644 --- a/src/interactions/leaderAdd.js +++ b/src/interactions/leaderAdd.js @@ -9,7 +9,7 @@ const interactionLeaderAdd = (bot, message) => { const { user, text, channel } = message if (text === '' || text === 'help') { - bot.whisper(message, transcript('leaderAdd.help')) + bot.replyPrivateDelayed(message, transcript('leaderAdd.help')) return } @@ -19,19 +19,19 @@ const interactionLeaderAdd = (bot, message) => { console.log( `${commandUser.user} isn't a leader, so I told them this was restricted` ) - bot.whisper(message, transcript('leaderAdd.invalidUser')) + bot.replyPrivateDelayed(message, transcript('leaderAdd.invalidUser')) return } if (!commandUser.club) { console.log(`${commandUser.user} doesn't have a club`) - bot.whisper(message, transcript('leaderAdd.invalidClub')) + bot.replyPrivateDelayed(message, transcript('leaderAdd.invalidClub')) return } if (commandUser.club.fields['Slack Channel ID'] != channel) { console.log(`${user} doesn't own channel ${channel}`) - bot.whisper(message, transcript('leaderAdd.invalidChannel')) + bot.replyPrivateDelayed(message, transcript('leaderAdd.invalidChannel')) return } @@ -68,14 +68,17 @@ const interactionLeaderAdd = (bot, message) => { // ensure we can assign the leader to this club const clubs = taggedUser.leader.fields['Clubs'] || [] if (clubs.includes(commandUser.club.id)) { - bot.whisper(message, transcript('leaderAdd.alreadyLeader')) + bot.replyPrivateDelayed( + message, + transcript('leaderAdd.alreadyLeader') + ) return } clubs.push(commandUser.club.id) return airPatch('Leaders', taggedUser.leader.id, { Clubs: clubs, }).then(() => { - bot.whisper( + bot.replyPrivateDelayed( message, transcript('leaderAdd.success', { taggedUserID, channel }) ) @@ -84,7 +87,7 @@ const interactionLeaderAdd = (bot, message) => { }) .catch(err => { console.error(err) - bot.whisper(message, transcript('errors.general', { err })) + bot.replyPrivateDelayed(message, transcript('errors.general', { err })) }) }