File size: 1,746 Bytes
23bbc26 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | const fs = require("fs-extra");
module.exports = {
config: {
name: "backupdata",
version: "1.2",
author: "NTKhang",
countDown: 5,
role: 2,
shortDescription: {
vi: "Sao lưu dữ liệu",
en: "Backup data"
},
longDescription: {
vi: "Sao lưu dữ liệu của bot (threads, users, dashboard, globalData)",
en: "Backup data of bot (threads, users, dashboard, globalData)"
},
category: "owner",
guide: {
en: " {pn}"
}
},
langs: {
vi: {
backedUp: "Đã sao lưu dữ liệu của bot vào thư mục scripts/cmds/tmp"
},
en: {
backedUp: "Bot data has been backed up to the scripts/cmds/tmp folder"
}
},
onStart: async function ({ message, getLang, threadsData, usersData, dashBoardData, globalData }) {
const [globalDataBackup, threadsDataBackup, usersDataBackup, dashBoardDataBackup] = await Promise.all([
globalData.getAll(),
threadsData.getAll(),
usersData.getAll(),
dashBoardData.getAll()
]);
const pathThreads = `${__dirname}/tmp/threadsData.json`;
const pathUsers = `${__dirname}/tmp/usersData.json`;
const pathDashBoard = `${__dirname}/tmp/dashBoardData.json`;
const pathGlobal = `${__dirname}/tmp/globalData.json`;
fs.writeFileSync(pathThreads, JSON.stringify(threadsDataBackup, null, 2));
fs.writeFileSync(pathUsers, JSON.stringify(usersDataBackup, null, 2));
fs.writeFileSync(pathDashBoard, JSON.stringify(dashBoardDataBackup, null, 2));
fs.writeFileSync(pathGlobal, JSON.stringify(globalDataBackup, null, 2));
message.reply({
body: getLang("backedUp"),
attachment: [
fs.createReadStream(pathThreads),
fs.createReadStream(pathUsers),
fs.createReadStream(pathDashBoard),
fs.createReadStream(pathGlobal)
]
});
}
}; |