好的,所以最近我想制作一个setup.js来编写我的config.json,但是idk为什么它会有一个错误。
我不知道js是怎么工作的
我的代码是
const rl = require("readline-sync");
const fs = require("fs");
let none = " change this crack to password if u wanna use premium account";
let ip,
user,
pass;
ip = rl.question("Enter the server that the bot will run on: ");
user = rl.question("Enter the MC account email/username: ");
pass = rl.question(' is your minecraft account crack ? ', {
trueValue: ['yes'],
falseValue: ['no']
});
if (pass === true) {
let cracka = true;
console.log("ok minecraft account setted to crack")
} else if (pass === false) {
let cracka = false;
rl.question("Enter the MC account password: ");
} else {
console.log('Sorry. What does "' + pass + '" you said mean?');
}
console.clear();
console.log("Server: " + ip);
console.log("User: " + user);
console.log("Password: " + pass);
if (rl.keyInYNStrict("Is this ok? ")) {
console.clear();
fs.writeFileSync(
"config.json",
JSON.stringify({
server: ip,
username: user,
if (cracka = true) {
crack: none,
} else if (cracka = false) {
password: pass,
}
})
);
rl.keyInPause("File created. You now can run the program.");
} else {
rl.keyInPause("OK. Cancelling...");
}
错误是
}else if (cracka = false) {
^
SyntaxError: Unexpected token '}'
[90m at wrapSafe (internal/modules/cjs/loader.js:1054:16)[39m
[90m at Module._compile (internal/modules/cjs/loader.js:1102:27)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:986:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:879:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m
[90m at internal/main/run_main_module.js:17:47[39m
我会改变这个:
if (rl.keyInYNStrict("Is this ok? ")) {
console.clear();
fs.writeFileSync(
"config.json",
JSON.stringify({
server: ip,
username: user,
if (cracka = true) {
crack: none,
} else if (cracka = false) {
password: pass,
}
})
);
对此:
if (rl.keyInYNStrict("Is this ok? ")) {
console.clear();
if (cracka) {
fs.writeFileSync(
"config.json",
JSON.stringify({
server: ip,
username: user,
crack: none
})
);
} else {
fs.writeFileSync(
"config.json",
JSON.stringify({
server: ip,
username: user,
password: pass
})
);
}
}