avamaxboobs
Version:
A package for randomly selecting images of various people's boobs. Intended to be used for discord bot commands.
24 lines (20 loc) • 831 B
JavaScript
const os = require('os')
const path = require('path')
const fs = require('fs')
/**
* Loads all backup files located in the backups folder
*/
async function LoadAllBackups(){
const dir = path.join(path.join(__dirname,'../../../../'),'avamaxboobs-backups');
if(!fs.existsSync(dir)) throw new Error('You don\'t have any backups to load! Use the CreateBackup() function to create one!')
const backupfolder = fs.readdirSync(dir).filter(file=>file.endsWith('.json'));
backupfolder.forEach(backup=>{
const backupfile = fs.readFileSync(path.join(dir,`${backup}`))
const json = JSON.parse(backupfile)
const jsonstring = JSON.stringify(json)
fs.writeFileSync(path.join(__dirname.slice(0,__dirname.length-15),'lists',`${backup}`),jsonstring)
})
}
module.exports={
LoadAllBackups
}