-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
469 lines (436 loc) · 21.2 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
const Discord = require('discord.js-selfbot-v13')
const client = new Discord.Client({
checkUpdate: false
})
const config = require('./config.json')
const backup = require('discord-backup')
const c = require('gradient-string')
const q = require('readline-sync')
const fs = require('fs')
const os = require("node:os")
if (!fs.existsSync("./backups")) fs.mkdirSync("./backups")
if (!fs.existsSync("./emotes")) fs.mkdirSync("./emotes")
backup.setStorageFolder(__dirname + "/backups/");
const language = (fr, en) => {
switch (config.language) {
case "en":
return en
case "fr":
return fr
default:
return en
}
}
const color = () => {
switch (config.color) {
case "blue":
return ["#3c00ff", "#07d6fa"]
case "green":
return ["#4dff00", "#00ff88"]
case "pink":
return ["#f5008f", "#f500dc"]
case "red":
return ["#f50018", "#f54e00"]
case "cyan":
return ["#00f59b", "#00f5e5", "#00f5e5"]
case "orange":
return ["#f54e00", "#f59f00"]
case "yellow":
return ["#f5cc00", "#d4f500"]
default:
return ["#3c00ff", "#07d6fa"]
}
}
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const makeid = (length) => {
var result = "";
var characters = "0123456789";
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(
Math.floor(Math.random() * charactersLength)
);
}
return result;
}
client.login(config.token || process.env.token).catch((e) => {
console.log(`Error: ${e}`)
const token = q.question(language("Quel est le token du selfbot/bot : ", "What's the token of the selfbot/bot : "))
config.token = token
fs.writeFile(`./config.json`, JSON.stringify(config, null, 4), err => err ? console.log(err) : "")
})
const main = async () => {
console.clear()
console.log(c(color())(`
${os.platform === "win32" ?
`
██████╗ █████╗ ██████╗██╗ ██╗██╗ ██╗██████╗ ████████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗
██╔══██╗██╔══██╗██╔════╝██║ ██╔╝██║ ██║██╔══██╗ ╚══██╔══╝██╔═══██╗██╔═══██╗██║ ██║ ██║╚════██╗
██████╔╝███████║██║ █████╔╝ ██║ ██║██████╔╝ ██║ ██║ ██║██║ ██║██║ ██║ ██║ █████╔╝
██╔══██╗██╔══██║██║ ██╔═██╗ ██║ ██║██╔═══╝ ██║ ██║ ██║██║ ██║██║ ╚██╗ ██╔╝██╔═══╝
██████╔╝██║ ██║╚██████╗██║ ██╗╚██████╔╝██║ ██║ ╚██████╔╝╚██████╔╝███████╗ ╚████╔╝ ███████╗
╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝`:
`______ _ _____ _ _ _ _____
| ___ \\ | | |_ _| | | | | | |/ __ \\
| |_/ / __ _ ___| | ___ _ _ __ | | ___ ___ | | | | | |\\\`' / /'
| ___ \\/ _\\\` |/ __| |/ / | | | '_ \\ | |/ _ \\ / _ \\| | | | | | / /
| |_/ / (_| | (__| <| |_| | |_) | | | (_) | (_) | | \\ \\_/ /./ /___
\\____/ \\__,_|\\___|_|\\_\\\__,_| .__/ \\_/\\___/ \\___/|_| \\___/ \\_____/`}
| |
|_| `))
console.log(c(color().reverse())("========================================================================================================================"))
console.log(c(color())(`
${os.platform === "win32" ? " " : ""}[1] - ${language("Créé Une Backup", "Create A Backup")}
${os.platform === "win32" ? " " : ""}[2] - ${language("Créé Une Backup (Sans Chargement)", "Create A Backup (Without Loading)")}
${os.platform === "win32" ? " " : ""}[3] - ${language("Créé Une Backup Des Emotes", "Create A Backup Of Emotes")}
${os.platform === "win32" ? " " : ""}[4] - ${language("Créé Une Backup (Avec les Messages)", "Create A Backup (With Messages)")}
${os.platform === "win32" ? " " : ""}[5] - ${language("Charger une Backup", "Load A Backup")}
${os.platform === "win32" ? " " : ""}[6] - ${language("Supprime Les Tickets (Par nom)", "Delete Tickets (Delete By Name)")}
${os.platform === "win32" ? " " : ""}[7] - ${language("Supprime Les Tickets (d'une Categorie)", "Delete Tickets (Delete From Category)")}
${os.platform === "win32" ? " " : ""}[8] - ${language("Créé Un Modèle (Besoin de Permissions)", "Create A Template (need permissions)")}
${os.platform === "win32" ? " " : ""}[9] - ${language("Affiche La Liste Des Backups", "See The List Of Backups")}
${os.platform === "win32" ? " " : ""}[0] - ${language("Fermer", "Exit")}`))
const choix = q.question(c(color())(language("Quel est votre Choix ? : ", "What's your Choice ? : ")))
switch (parseInt(choix)) {
default:
console.log(c(color())("Missclick ??"))
sleep(2000)
.then(() => main())
break
case 1: {
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
console.log(c(color())(language("Création de la backup en cours...", "Creation of the current backup...")))
const bkp = await backup.create(guild, {
maxMessagesPerChannel: 0,
jsonSave: true,
jsonBeautify: true,
doNotBackup: ["emojis", "bans"]
});
const newguild = await client.guilds.create("Backup Tool V2")
console.log(c(color())(language("Chargement de la backup en cours...", 'Loading the current backup...')))
let cc = 0
bkp.channels.categories.forEach((c) => c.children.forEach(() => cc = cc + 1))
bkp.channels.others.forEach(() => cc = cc + 1)
backup.load(bkp.id, newguild)
setTimeout(async () => {
console.log(c(color())(language("Chargement terminé", "Loading finished")))
await sleep(5000)
return main()
}, cc * 1000 + 12 * 1000);
break;
}
case 2: {
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
console.log(c(color())(language("Création de la backup en cours...", "Creation of the current backup...")))
const bkp = await backup.create(guild, {
maxMessagesPerChannel: 0,
jsonSave: true,
jsonBeautify: true,
doNotBackup: ["emojis", "bans"]
});
console.log(c(color())(language(`Voici l'ID de votre backup: ${bkp.id}`, `That's the ID of your backup: ${bkp.id}`)))
q.question(c(color())(language("Appuyez sur espace pour continuer...", "Press the space button for continue")))
main()
break
}
case 3: {
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
let backupid = makeid(16)
const er = new Array()
guild.emojis.cache.forEach(e => er.push(`"${e.toString()}"`))
if (!fs.existsSync(`./emotes/${backupid}.json`)) fs.writeFileSync(`./emotes/${backupid}.json`, `{\n "emojis": [${er}],\n "name": "${guild.name}",\n "code": "${backupid}",\n "size": "${guild.emojis.cache.size}"\n}`)
console.log(c(color())(language(`Voici l'ID de la backup d'emotes: ${backupid}`, `That's the ID of the emote backup: ${backupid}`)))
q.question(c(color())(language("Appuyez sur espace pour continuer...", "Press the space button for continue")))
main()
break
}
case 4: {
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
console.log(c(color())(language("Création de la backup en cours...", "Creation of the current backup...")))
const bkp = await backup.create(guild, {
maxMessagesPerChannel: 10,
jsonSave: true,
jsonBeautify: true,
doNotBackup: ["emojis", "bans"],
saveImages: "base64"
});
const newguild = await client.guilds.create("Backup Tool V2")
console.log(c(color())(language("Chargement de la backup en cours...", 'Loading the current backup...')))
let cc = 0
bkp.channels.categories.forEach((c) => c.children.forEach(() => cc = cc + 1))
bkp.channels.others.forEach(() => cc = cc + 1)
backup.load(bkp.id, newguild)
setTimeout(async () => {
console.log(c(color())(language("Chargement terminé", "Loading finished")))
await sleep(5000)
return main()
}, cc * 1000 + 12 * 1000);
break;
}
case 5: {
const bkpid = q.question(c(color())(language("Veuillez me donner l'ID de la Backup : ", "Give me the ID of the Backup : ")))
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
if (fs.existsSync(`./emotes/${bkpid}.json`)) {
if (!guild.members.me.permissions.has("MANAGE_EMOJIS_AND_STICKERS")) {
console.log(c(color())(language("Il vous faut la permissions MANAGE_EMOJIS", "You need the MANAGE_EMOJIS permissions")))
await sleep(2000)
return main()
}
let cc = 1
const data = require(`./emotes/${bkpid}.json`)
await data.emojis.forEach(async emote => {
let emoji = Discord.Util.parseEmoji(emote);
if (emoji.id) {
const Link = `https://cdn.discordapp.com/emojis/${emoji.id}.${emoji.animated ? 'gif' : 'png'}`;
guild.emojis
.create(`${Link}`, `${`${emoji.name}`}`)
.then(() => {
console.log(c(color())(language(`[${cc + "/" + data.size}] ${emoji.name} créé`, `[EMOTE] ${emoji.name} created`)));
cc = cc + 1
})
.catch((err) => {
console.log(c(color())(`[ERR] ${err}`));
cc = cc + 1
})
if (cc === data.size) {
console.log(c(color())(language("Les emotes ont été créés", "The emotes has been created")))
await sleep(3000)
main()
}
}
})
} else if (backup.fetch(bkpid)) {
if (!guild.members.me.permissions.has("ADMINISTRATOR")) {
console.log(c(color())(language("Il vous faut la permissions ADMINISTRATEUR", "You need the ADMINITRATOR permissions")))
await sleep(2000)
return main()
}
const bkpp = await backup.fetch(bkpid)
let cc = 0
bkpp.data.channels.categories.forEach((c) => c.children.forEach(() => cc = cc + 1))
bkpp.data.channels.others.forEach(() => cc = cc + 1)
backup.load(bkpp.id, guild)
setTimeout(async () => {
console.log(c(color())(language("Chargement terminé", "Loading finished")))
await sleep(5000)
return main()
}, cc * 1000 + 12 * 1000);
} else {
console.log(c(color())(language("Aucune backup de trouvée", "No backup found")))
await sleep(2000)
main()
}
break
}
case 6: {
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
if (!guild.members.me.permissions.has("MANAGE_CHANNELS")) {
console.log(c(color())(language("Vous n'avez pas les permissions nécessaires: Gérer Les Salons", "You didn't have the permissions Manage Channels")))
await sleep(2000)
return main()
}
const name = q.question(c(color())(language("Quel est le nom des salons a supprimer (ex: ticket-) : ", "What's the name of channels to be deleted (ex: ticket-) : ")))
if (!name) {
console.log(c(color())(language("Veuillez me donner un nom valide", "Give me a valid name")))
await sleep(2000)
return main()
}
let del = 1
const num = guild.channels.cache.filter(c => c.name.includes(name)).size
if (num === 0) {
console.log(c(color())(language("Aucun salon a supprimer de trouvé", "No channel to delete found")))
await sleep(2000)
main()
}
guild.channels.cache
.filter(ch => ch.name.includes(name))
.forEach(ch => ch.delete()
.then(async () => {
console.log(c(color())(language(`[${del}/${num}] Le salon ${ch.name} a été supprimé`, `[${del}/${num}] The channel ${ch.name} has been deleted`)))
del = del + 1
if (del === num) {
await sleep(2000)
return main()
}
})
.catch(async () => {
console.log(c("#07d6fa", "#3c00ff")(language(`[${del}/${num}] Le salon ${ch.name} n'a pas pu être supprimé`, `[${del}/${num}] The channel ${ch.name} cannot be delete`)))
del = del + 1
if (del === num) {
await sleep(2000)
return main()
}
})
)
break
}
case 7: {
const cat = q.question(c(color())(language("Quel est l'ID de la categorie : ", "What's the ID of the category : ")))
const channel = client.channels.cache.get(cat)
if (!channel || channel.type !== "GUILD_CATEGORY") {
console.log(c(color())(language("Aucune catégorie de trouvée", "No category found")))
await sleep(2000)
return main()
}
if (!channel.guild.members.me.permissions.has("MANAGE_CHANNELS")) {
console.log(c(color())(language("Vous n'avez pas les permissions nécessaires: Gérer Les Salons", "You didn't have the permissions Manage Channels")))
await sleep(2000)
return main()
}
if (!channel.children) {
console.log(c(color())(language("Cette catégorie ne contient pas de salon", "This category don't have any channel")))
await sleep(2000)
return main()
}
let del = 1
let num = 0
channel.children.forEach(() => num = num + 1)
channel.children.forEach(ch => ch.delete()
.then(async () => {
console.log(c(color())(language(`[${del}/${num}] Le salon ${ch.name} a été supprimé`, `[${del}/${num}] The channel ${ch.name} has been deleted`)))
del = del + 1
if (del === num) {
await sleep(2000)
return main()
}
})
.catch(async () => {
console.log(c("#07d6fa", "#3c00ff")(language(`[${del}/${num}] Le salon ${ch.name} n'a pas pu être supprimé`, `[${del}/${num}] The channel ${ch.name} cannot be delete`)))
del = del + 1
if (del === num) {
await sleep(2000)
return main()
}
})
)
break
}
case 8: {
const askguild = q.question(c(color())(language("Veuillez me donner l'ID du serveur : ", "Give me the ID of the guild : ")))
await client.guilds.fetch()
const guild = client.guilds.cache.get(askguild)
if (!guild) {
console.log(c(color())(language("Serveur non trouvé", "Guild not found")))
await sleep(2000)
return main()
}
if (!guild.members.me.permissions.has("MANAGE_GUILD")) {
console.log(c(color())(language("Vous n'avez pas les permissions nécessaires: Gérer Le Serveur", "You didn't have the permissions Manage Guild")))
await sleep(2000)
return main()
}
const ask = () => {
q.question(c(color())(language("Appuyez sur espace pour continuer...", "Press the space button for continue")))
return main()
}
guild.createTemplate(`${guild.name}`, `Backup Tool V2`)
.then((l) => {
console.log(c(color())(l.url))
ask()
})
.catch(() => {
guild.fetchTemplates()
.then(l => {
console.log(c(color())(`https://discord.new/${l.first()}`))
ask()
})
.catch((err) => {
console.log(c(color())(`[ERR] ${err}`))
ask()
})
})
break
}
case 9: {
backup.list().then(async (backups) => {
let backupFetched = [];
for (let i = 0; i < backups.length; i++) {
const fetchingBackup = await backup.fetch(backups[i])
backupFetched.push(fetchingBackup)
}
const backupInfos = (await Promise.all(backupFetched.sort(function(a, b) {
return a.data.name.localeCompare(b.data.name)
}).map((e, i) => `${e.data.name}\` ➜ ${e.id}`))).join('\n')
console.log(c(color())(`${backupInfos.length > 0 ? backupInfos : language("Aucune backup", "No Backup")}`))
let backupemotes = []
const emotes = fs.readdirSync(`./emotes/`).filter(files => files.endsWith(".json"));
for (const file of emotes) {
const cont = require(`./emotes/${file}`)
backupemotes.push(`${cont.name} ➜ ${cont.code}`)
}
console.log(c(color(), color())("========================================================================================================================"))
console.log(c(color())(`${backupemotes.length > 0 ? backupemotes : language("Aucune backup d'emoji", "No Emoji's Backup")}`))
console.log("\n")
q.question(c(color())(language("Appuyez sur espace pour continuer...", "Press the space button for continue")))
return main()
})
break
}
case 0:
process.exit()
}
}
client.once('ready', () => main())
// ANTI CRASH
process.on("unhandledRejection", (reason, p) => {
if (reason.code === 0) return; // 404: Not Found
if (reason.code === 400) return; // Invalid Token
if (reason.code == 10062) return; // Unknown interaction
if (reason.code == 10008) return; // Unknown message
if (reason.code === 50035) return; // Invalid Form Body
if (reason.code === 40032) return; // Not Connected At Voice
if (reason.code == 50013) return; // Missing permissions
if (reason.message.includes("GUILD_VOICE")) return; //CACHE LE MESSAGE INUTILE "GUILD_VOICE"
if (reason.message.includes("Temp env not set")) return; // Bug Stream
if (reason.message.includes('no such file or director')) return; // Bug Stream
if (reason.message.includes("getaddrinfo ENOTFOUND null")) return; // Bug Vocale
console.log(reason, p);
});
process.on("uncaughtException", (err, origin) => {
//console.log(err, origin);
});
process.on("multipleResolves", (type, promise, reason) => {
//console.log(type, promise, reason);
})