fix roletip
This commit is contained in:
parent
4dcaea3370
commit
34151fc92b
1 changed files with 17 additions and 17 deletions
|
@ -230,23 +230,26 @@ function doRoleTip(bot, message, tipper, words, helpmsg, MultiorRole) {
|
||||||
doHelp(message, helpmsg);
|
doHelp(message, helpmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let prv = false;
|
let isPrivateTip = words.length >= 4 && words[1] === 'private';
|
||||||
let amountOffset = 2;
|
let amountOffset = isPrivateTip ? 3 : 2;
|
||||||
if (words.length >= 4 && words[1] === 'private') {
|
|
||||||
prv = true;
|
|
||||||
amountOffset = 3;
|
|
||||||
}
|
|
||||||
let amount = getValidatedAmount(words[amountOffset]);
|
let amount = getValidatedAmount(words[amountOffset]);
|
||||||
if (amount == null) {
|
if (amount === null) {
|
||||||
message.reply("I don't know how to tip that amount of LBC...").then(message => message.delete(10000));
|
message.reply("I don't know how to tip that amount of LBC...").then(message => message.delete(10000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message.mentions.roles.first().id) {
|
|
||||||
if (message.mentions.roles.first().members.first().id) {
|
let roleToTip = message.mentions.roles.first();
|
||||||
let userIDs = message.mentions.roles.first().members.map(member => member.user.id.replace('!', ''));
|
if (roleToTip !== null) {
|
||||||
for (let i = 0; i < userIDs.length; i++) {
|
let membersOfRole = message.mentions.roles
|
||||||
sendLBC(bot, message, tipper, userIDs[i].toString(), amount, prv, MultiorRole);
|
.first()
|
||||||
}
|
.members.first()
|
||||||
|
.keyArray();
|
||||||
|
if (membersOfRole.length > 0) {
|
||||||
|
let userIDs = membersOfRole.map(member => member.user.id.replace('!', ''));
|
||||||
|
userIDs.forEach(u => {
|
||||||
|
sendLBC(bot, message, tipper, u, amount, isPrivateTip, MultiorRole);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return message.reply('Sorry, I could not find any users to tip in that role...').then(message => message.delete(10000));
|
return message.reply('Sorry, I could not find any users to tip in that role...').then(message => message.delete(10000));
|
||||||
}
|
}
|
||||||
|
@ -329,10 +332,7 @@ function inPrivateOrBotSandbox(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValidatedAmount(amount) {
|
function getValidatedAmount(amount) {
|
||||||
amount = amount.trim();
|
amount = amount.toLowerCase().replace('lbc', '');
|
||||||
if (amount.toLowerCase().endsWith('lbc')) {
|
|
||||||
amount = amount.substring(0, amount.length - 3);
|
|
||||||
}
|
|
||||||
return amount.match(/^[0-9]+(\.[0-9]+)?$/) ? amount : null;
|
return amount.match(/^[0-9]+(\.[0-9]+)?$/) ? amount : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue