MCPcopy Create free account
hub / github.com/IceClusters/icmysql / SaveData

Function SaveData

src/json/Save.js:3–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1const { SendDiscordLog } = require('../utils/Discord.js');
2
3async function SaveData() {
4 if (changedFiles.length == 0) return;
5 for (let i = 0; i < changedFiles.length; i++) {
6 if (await FileExist(Config.SaveDirPath + "/" + changedFiles[i] + ".json")) {
7 await ModifyData(Config.SaveDirPath + "/" + changedFiles[i] + ".json", JSON.stringify(loadedData[changedFiles[i]]));
8 }
9 else {
10 await CreateIfNotExist(Config.SaveDirPath + "/" + changedFiles[i] + ".json", JSON.stringify(loadedData[changedFiles[i]]));
11 }
12 }
13 Log(LogTypes.Debug, `Saved data of ${changedFiles.map(file => file).join(", ")}`);
14 if (Config.SendSaveData)
15 SendDiscordLog({
16 "content": null,
17 "embeds": [
18 {
19 "title": "JSON Saved",
20 "description": "The JSON files have been saved successfully.\n `" + changedFiles.map(file => file).join("\n") + "`",
21 "color": 16773720
22 }
23 ],
24 "attachments": []
25 })
26 changedFiles = [];
27
28}
29
30global.exports('SaveData', SaveData);

Callers

nothing calls this directly

Calls 4

FileExistFunction · 0.85
ModifyDataFunction · 0.85
CreateIfNotExistFunction · 0.85
LogFunction · 0.85

Tested by

no test coverage detected