Answer the question
In order to leave comments, you need to log in
What is this "Cannot read property '1' of undefined" error on Node JS?
I'm making a game bot in VK and in order to withdraw extra funds from the project, I need to make a casino, but I just don't understand why it doesn't work...
vk.updates.hear(/^(?:казино)\s?(.*)?/i, async (message, args, bot, next) => {
var id = await find(message.senderId);
message.args[1] = message.args[1].replace(/(\.|\,)/ig, '');
message.args[1] = message.args[1].replace(/(к|k)/ig, '000');
message.args[1] = message.args[1].replace(/(м|m)/ig, '000000');
if(!Number(message.args[1])) return;
message.args[1] = Math.floor(Number(message.args[1]));
if(message.args[1] <= 0) return;
if(message.args[1] > users[id].balance) return message.send(`у вас нет данной суммы`);
else if(message.args[1] <= users[id].balance)
{
users[id].balance -= message.args[1];
const multiply = utils.pick([0.75, 0.75, 2, 0.75, 0.75, 0.5, 0.75, 0.75, 0.75, 0.75, 0.75, 0.25, 0.75, 0.75, 0.75, 2, 0.75, 5, 0.75, 0.5, 0.75, 0.75, 0.75, 0.75, 0.75, 0.25, 0.75, 2]);
users[id].balancee += Math.floor(message.args[1] * multiply);
return message.send(`${['','', '', '', ''].random()} >> ${multiply === 1 ? `Ваши деньги остаются при вас!` : `${multiply < 1 ? `Вы проиграли ${utils.sp(message.args[1] * multiply)}₽` : `Вы выиграли ${utils.sp(message.args[1] * multiply)}₽`}`}
❤ >> Сумма умножена в x${multiply}
Ваш баланс: ${utils.sp(users[id].balance)}₽`);
}
});
Answer the question
In order to leave comments, you need to log in
You get the 1st index from undefined
message.args[1] = message.args[1].replace(/(\.|\,)/ig, '');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question