-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
53 lines (44 loc) · 1.63 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
47
48
49
50
51
52
/*@cc_on
@if (@_jscript)
var shell = WScript.CreateObject("WScript.Shell");
shell.Run("https://github.com/Tenrys/discord-emoji-stealer/blob/master/README.md#usage");
WScript.Quit();
@else@*/
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()
})
require("./get_token.js")().then(token => client.login(token))
/*@end@*/