Upon implementing the code you suggested, I encountered some difficulties.
` switch (args[2]) {
case 'Freekill': {
let points = "20";
fs.writeFile('./warnLevel.json', points, (error) => {
if (error) throw err;
})
break;
}
case 'Spam' : {
let points = "10";
fs.writeFile('./warnLevel.json', points, (error) => {
if (error) throw err;
})
break;
}
}
break;
} `
I faced two primary issues:
1) The command was overwriting all existing data in the JSON file rather than tracking individual users' points.
2) When I added the second case, I encountered the following error:
internal/modules/cjs/loader.js:1175
throw err;
^
SyntaxError: C:\Users\ACER\Desktop\PobWarn\warnLevel.json: Unexpected end of JSON input
at parse (<anonymous>)
?[90m at Object.Module._extensions..json (internal/modules/cjs/loader.js:1172:22)?[39m
?[90m at Module.load (internal/modules/cjs/loader.js:986:32)?[39m
?[90m at Function.Module._load (internal/modules/cjs</answer2>
<exanswer2><div class="answer" i="62289185" l="4.0" c="1591715287" a="U2FwcGV1cg==" ai="13713775">
<p>So I experimented with the commands you mentioned.</p>
<pre><code>` switch (args[2]) {
case 'Freekill': {
let data = "20";
fs.writeFile('./warnLevel.json', data, (error) => {
if (error) throw err;
})
break;
}
case 'Spam' : {
let data = "10";
fs.writeFile('./warnLevel.json', data, (error) => {
if (error) throw err;
})
break;
}
}
break;
} `
I encountered two main obstacles:
1) The command kept replacing all contents in the JSON file instead of maintaining different users' points.
2) Adding the second case resulted in this error message:
internal/modules/cjs/loader.js:1175
throw err;
^
SyntaxError: C:\Users\ACER\Desktop\PobWarn\warnLevel.json: Unexpected end of JSON input
at parse (<anonymous>)
?[90m at Object.Module._extensions..json (internal/modules /cjs/loader.js:1172:22)?[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 Module.require (internal/modules/cjs/loader.js:1026:19)?[39m
?[90m at require (internal/modules/cjs/helpers.js:72:18)?[39m
at Object.<anonymous> (C:\Users\ACER\Desktop\PobWarn\index.js:6:19)
?[90m at Module._compile (internal/modules/cjs/loader.js:1138:30)?[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
Additionally, I am uncertain about the purpose and parameters to be used for the `readFile` command, including options and callback functions. Apologies for any inconvenience caused.