В настоящее время я пишу бот-диск с использованием discord.js и застрял на этой ошибке:
UnhandledPromiseRejectionWarning: TypeError: Cannot create property 'reply' on number '1000'
Ошибка появляется каждый раз, когда «Ограбление» проходит успешно.
Это мой код:
const Discord = require('discord.js');
const fs = require('fs');
let coins = JSON.parse(fs.readFileSync('./coins.json', 'utf8'));
module.exports.run = async (bot, message, args) => {
let userDiff = args[0];
let userChance = 0.333 * userDiff;
var userEarned = 0
let numAmt = Math.floor(Math.random() * userDiff) + 1;
if(userDiff > 10){
messange.channel.send('Please enter a number between 1-10')
} else if(userDiff <= 10 && userDiff >= 9){
var userEarned = 1000
} else if(userDiff < 9 && userDiff >= 8){
var userEarned = 900
} else if(userDiff < 8 && userDiff >= 7){
var userEarned = 800
} else if(userDiff < 7 && userDiff >= 6){
var userEarned = 700
} else if(userDiff < 6 && userDiff >= 5){
var userEarned = 600
} else if(userDiff < 5 && userDiff >= 4){
var userEarned = 500
} else if(userDiff < 4 && userDiff >= 3){
var userEarned = 400
} else if(userDiff < 3 && userDiff >= 2){
var userEarned = 300
} else if(userDiff < 2 && userDiff >= 1){
var userEarned = 200
}
console.log('numAmt: ', numAmt);
console.log('userChance: ', userChance);
if(numAmt <= userChance){
message.channel.send('Robbery was Succesful you earned ', userEarned)
coins[message.author.id]['coins'] += userEarned
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if (err) console.log(err)
});
}
if(numAmt >= userChance){
message.channel.send('Robbery was Unsuccesful you have been arested, You can pay to bail out or wait 5 mins')
}
}
module.exports.help = {
name: 'bankrobbery'
}