global.FolderPath = path.join(os.homedir(), "data")
global.DataPath = path.join(global.FolderPath, "data.json")
let Data: {[key: string]: Configuration} = {};
if (fs.existsSync(global.DataPath)) {
const fileContent = fs.readFileSync(global.DataPath, "utf-8");
if (typeof fileContent === "string") {
try {
Data = JSON.parse(fileContent) as {[key: string]: Configuration};
} catch (error) {
console.error("Error parsing JSON:", error);
}
} else {
console.error("File content is not a string.");
}
} else {
console.warn(`File does not exist at ${global.DataPath}. Creating a new file.`);
}
// If the folder doesn't exist, create it and write an empty object to the file
if (!fs.existsSync(global.FolderPath)) {
fs.mkdirSync(global.FolderPath);
fs.writeFileSync(global.DataPath, "{}");
}
process.on("unhandledRejection", (error) => {
console.error(error);
// Assuming log is defined elsewhere
log("Unhandled Rejection Found!", "PROMISE.ERROR");
});
Here the code asks for a token value as a string and when i input it it shows me an error of invalid argument type as above in the image..
I tried to input a string but also it showed a npm warn about the string similarity package 4.0.4 i wonder if thats the issue
New contributor