Skip to content

Commit

Permalink
tacobot now stops talking. He just adds a reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinleiba committed Apr 9, 2019
1 parent 0c3e556 commit e635e86
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 11,21 @@ const forTaco = controller => {
const senderIndex = ids.indexOf(message.user);
const tacosGiven = parser.countTacos(message.text);
if (userIndex > -1 && userIndex !== senderIndex) {
const user = DB.getUser(userIndex);
const giver = DB.getUser(senderIndex);
if (giver.left >= tacosGiven) {
taco.giveTaco(userIndex, tacosGiven);
taco.removeLeft(senderIndex, tacosGiven);
bot.reply(
message,
`Congratz ! <@${user.id}> now has ${user.tacos
tacosGiven} tacos !`
);
bot.reply(
message,
`<@${message.user}> now has ${giver.left -
tacosGiven} tacos left... Nice job guys`
bot.api.reactions.add(
{
timestamp: message.ts,
channel: message.channel,
name: "taco"
},
function(err, res) {
if (err) {
bot.botkit.log("Failed to add emoji reaction :(", err);
}
}
);
} else {
bot.reply(
Expand Down

0 comments on commit e635e86

Please sign in to comment.