forked from IRON-M4N/pair-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.js
More file actions
24 lines (19 loc) · 714 Bytes
/
connect.js
File metadata and controls
24 lines (19 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { File } = require('megajs');
const fs = require('fs');
var prefix = "IRON-M4N×"; //your prefix same as in config.PREFIX
var output = "./session/"; //path where the creds.json will save
async function saveCreds(id) {
if (!id.startsWith(prefix)) {
throw new Error(`Preix doesn't match check if "${prefix}" is correct`);
}
var url = `https://mega.nz/file/${id.replace(prefix, "")}`;
var file = File.fromURL(url);
await file.loadAttributes();
var pth = output + "creds.json";
if (!fs.existsSync(output)) {
fs.mkdirSync(output, { recursive: true });
}
var data = await file.downloadBuffer();
fs.writeFileSync(pth, data);
}
// https://mega.js.org/docs/1.0/tutorial/downloading