-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbackup.js
41 lines (39 loc) · 1.55 KB
/
backup.js
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
let { MessageType } = require('@adiwajshing/baileys')
let fs = require('fs')
let handler = async (m, { conn, DevMode }) => {
try {
let d = new Date
let date = d.toLocaleDateString('id', {
day: 'numeric',
month: 'long',
year: 'numeric'
})
await global.db.save()
await fs.copyFile(`./database.json`, `./database ${date}.json`, (err) => {
if (err) {
console.log(err)
if (DevMode) {
for (let jid of global.owner.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').filter(v => v != conn.user.jid)) {
conn.sendMessage(jid, 'Backup.js error\nNo: *' + m.sender.split`@`[0] + '*\nCommand: *' + m.text + '*\n\n*' + e + '*', MessageType.text)
}
}
} else {
m.reply('Berhasil!!')
console.log('database.json was copied to database ' + date + '.json')
}
})
} catch (e) {
console.log(e)
conn.reply(m.chat, 'Gunaan Format Yang benar', m)
if (DevMode) {
for (let jid of global.owner.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').filter(v => v != conn.user.jid)) {
conn.sendMessage(jid, 'Backup.js error\nNo: *' + m.sender.split`@`[0] + '*\nCommand: *' + m.text + '*\n\n*' + e + '*', MessageType.text)
}
}
}
}
handler.help = ['backup']
handler.tags = ['owner']
handler.command = /^(backup)$/i
handler.owner = true
module.exports = handler