-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (38 loc) · 1.42 KB
/
index.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
42
43
44
45
46
const Discord = require("discord.js");
const fs = require("fs");
const sanitize = require("sanitize-filename");
const https = require("https");
const path = require("path");
const shell = require("shelljs");
let client = new Discord.Client();
client.on("ready", async function() {
console.log("Logged in as " + this.user.username + ".");
let guilds = this.guilds.array();
for (const guild of guilds) {
let folderPath = path.join(__dirname, "emojis", sanitize(guild.name));
shell.mkdir("-p", folderPath);
let emojis = guild.emojis.array();
for (const emoji of emojis) {
let filePath = path.join(folderPath, emoji.name + path.extname(emoji.url));
if (!fs.existsSync(filePath)) {
await (new Promise(resolve => {
https.get(emoji.url, res => {
console.log(emoji.url + " => " + filePath);
let stream = fs.createWriteStream(filePath);
res.pipe(stream);
stream.on("finish", () => {
// console.log("Downloaded")
resolve();
});
});
}));
} else {
console.log(filePath + " exists, skipping");
}
}
}
console.log("Done!");
process.exit();
});
client.login('your_token_here');
/*@end@*/