From 8eb5bb9578d3fe86a233ada7479874de5bf9f597 Mon Sep 17 00:00:00 2001 From: ProfessorDey Date: Wed, 21 Feb 2018 19:52:46 +0000 Subject: [PATCH] Integrating final MSFT fixes Now the last little changes have been implemented, had to modify how we got the user to message since we were previously getting the first user mentioned in the message, whereas we now match against all known users in the guild. This means users actually get messaged by, say, rolebot even if they're not in the channel you're tipping from. Of course you can't directly mention anyone not in the channel for multitip, so that's a non-issue in most use cases. Also had to ensure certain function calls were sending the right type, because dynamic languages and lack of type safety. That _should_ be absolutely everything needed to have it fully functional. --- bot/modules/tipbot.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/modules/tipbot.js b/bot/modules/tipbot.js index c7f0748..3d0112c 100644 --- a/bot/modules/tipbot.js +++ b/bot/modules/tipbot.js @@ -274,8 +274,7 @@ function findUserIDsAndAmount(message, words, prv) { idList.push(words[i].match(/[0-9]+/)); } else { amount = getValidatedAmount(words[Number(count)+1]); - if (amount == null) break; - break + break; } } return [idList, amount]; @@ -283,12 +282,12 @@ function findUserIDsAndAmount(message, words, prv) { function sendLBC(message, tipper, recipient, amount, privacyFlag) { - getAddress(recipient, function (err, address) { + getAddress(recipient.toString(), function (err, address) { if (err) { message.reply(err.message).then(message => message.delete(5000)); } else { - lbry.sendFrom(tipper, address, amount, 1, null, null, function (err, txId) { + lbry.sendFrom(tipper, address, Number(amount), 1, null, null, function (err, txId) { if (err) { message.reply(err.message).then(message => message.delete(5000)); } @@ -299,8 +298,9 @@ function sendLBC(message, tipper, recipient, amount, privacyFlag) { var authmsg = 'You have just privately tipped <@' + recipient + '> ' + amount + ' LBC.\n' + tx + msgtail; message.author.send(authmsg); if (message.author.id != message.mentions.users.first().id) { + var usr = message.guild.members.find('id', recipient).user; var recipientmsg = 'You have just been privately tipped ' + amount + ' LBC by <@' + tipper + '>.\n' + tx + msgtail; - message.mentions.users.first().send(recipientmsg); + usr.send(recipientmsg); } } else { var generalmsg =