-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbladee.js
2189 lines (1849 loc) · 157 KB
/
bladee.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
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// API & Packages
const { MessageEmbed, Client, Collection, Intents } = require('discord.js');
const client = new Client({ disableMentions: "everyone" }, { ws: { intents: Intents.PRIVILEGED } });
const fs = require("fs");
const fileWriter = require("./fileWriter");
const path = require("path");
const mv = require('mv');
require("dotenv").config();
const server = require("./server");
const disbut = require("discord-buttons");
client.invites = {};
disbut(client);
// Config
client.config = require("./config.json");
// Settings
const { prefix, author, founderId, founder } = require('./commands/settings.json');
// Global Blacklisting
const GBlacklisted = require('./commands/database/global_blacklist/blacklist.json');
client.commands = new Collection();
let commandDir = "commands";
for (const category of fs.readdirSync(`./${ commandDir }`)) {
if (!fs.statSync(`./${ commandDir }/${ category }`).isDirectory()) continue;
const direc2 = fs.readdirSync(path.join(`./${ commandDir }/${ category }`)).filter(file => file.endsWith(".js"));
for (const f of direc2) {
const command = require(`./${ commandDir }/${ category }/${ f }`);
client.commands.set(command.name, command);
}
for (const folder of fs.readdirSync(`./${ commandDir }/${ category }`)) {
if (!fs.statSync(`./${ commandDir }/${ category }/${ folder }`).isDirectory()) continue;
const direc = fs.readdirSync(path.join(`./${ commandDir }/${ category }/${ folder }`)).filter(file => file.endsWith(".js"));
for (const f of direc) {
const command = require(`./${ commandDir }/${ category }/${ folder }/${ f }`);
client.commands.set(command.name, command);
}
for (const files of fs.readdirSync(`./${ commandDir }/${ category }/${ folder }`)) {
const command = require(`./${ commandDir }/${ category }/${ folder }/${ files }`);
client.commands.set(command.name, command);
}
}
}
// Listeners
process.setMaxListeners(300);
// Customizations
const { red, green, magenta, greenBright, magentaBright, yellowBright, blue, blueBright, grey, redBright, yellow, cyan, cyanBright } = require('chalk');
// Title
console.log(magenta(`
███╗ ███╗██╗ ██╗ ███╗ ██████╗
████╗ ████║╚██╗██╔╝ ████║ ██╔══██╗
██╔████╔██║ ╚███╔╝ ██╔██║ ██║ ██║
██║╚██╔╝██║ ██╔██╗ ╚═╝██║ ██║ ██║
██║ ╚═╝ ██║██╔╝╚██╗███████╗██████╔╝
╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═════╝
Anti Nuke | MX1D | Author: ${ author }
`));
client.on("ready", () => {
// UserCount
const userCount = client.guilds.cache.map((guild) => guild.memberCount).reduce((p, c) => p + c, 0);
// Login
console.log(magentaBright(' ════════════════════════════════════════════════════════════════════════════════'));
console.log(magentaBright(` Guardian: ${ client.user.username }#${ client.user.discriminator } `));
console.log(magentaBright(' ════════════════════════════════════════════════════════════════════════════════'));
// Status
// Status Title Options
// Status Activity Options
let ActiOptions = ["STREAMING", "PLAYING", "LISTENING", "WATCHING"];
setInterval(function () {
// Randomise
let randomsieActivity = ActiOptions[Math.floor(Math.random() * ActiOptions.length)];
// Activity
client.user.setActivity({
name: `${ userCount } users protected.`,
type: randomsieActivity,
url: "https://www.twitch.tv/ayoohennio"
});
}, 10000); // Change 10 Every Second(s)
});
// Commands
client.on("message", message => {
if (message.author.bot) return;
if (message.channel.type === 'dm') return;
if (!client.config[message.guild.id]) {
client.config[message.guild.id] = {
"ban": false,
"kick": false,
"roleCreate": false,
"roleUpdate": false,
"botAdd": false,
"memberJoin": false,
"channelCreate": false,
"channelDelete": false,
"webhookCreate": false,
"webhookDelete": false,
"RoleCreate": false,
};
fileWriter.config(client);
}
// Logs Command
if (message.content.startsWith(prefix)) {
const d = new Date();
const date = d.getHours() + ":" + d.getMinutes() + ", " + d.toDateString();
console.log(green(`[COMMAND RAN] : ${ message.content } | ${ message.author.tag } | [SERVER] : ${ message.guild.name } | [TIME] : ${ date }`));
// Args
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
let arry = ["bassboost", "clear", "config", "disconnect", "grab", "loop", "loopqueue", "lyrics", "nowplaying", "pause", "play", "queue", "remove", "resume", "search", "seek", "shuffle", "skip", "skipto", "volume", "stats", "youtube"];
if (!client.commands.has(command) && !arry.includes(command)) {
console.log("This command doesnt exist");
return;
}
if (arry.includes(command)) return;
try {
client.commands.get(command).run(client, message, args);
} catch (error) {
console.error(error);
}
}
});
client.on("guildCreate", async guild => {
console.log(greenBright(`\n[GUILD JOINED] ${ guild.name } | [ID] ${ guild.id } | [ (+) MEMBERCOUNT: ${ guild.memberCount }]\n`));
const path = `commands/database/backup_guilds/${ guild.id }.json`;
fs.access(path, fs.F_OK, (err) => {
if (err) {
console.error(greenBright('File: ' + path + ' does not exist so it is being created'));
function GuildData (ID, Name) {
ID = guild.id;
Name = guild.name;
const data = {
GuildID: ID,
GuildName: Name,
Data: {
Owner: guild.owner.user.tag,
OwnerID: guild.ownerID,
WhiteListedUserIDs: [],
WhiteListedUsers: [],
BlackListedUserIDs: [],
BlackListedUsers: [],
TrustListedUserIDs: [],
TrustListedUsers: [],
}
};
const content = JSON.stringify(data, null, 2);
fs.writeFile(`./commands/database/guilds/${ ID }.json`, content, 'utf8', function (err) {
if (err) {
return console.error(err);
}
});
}
GuildData();
} else {
return console.log(yellowBright('This guild has a database in the back up database | Must refer to it to get it back'));
}
});
return console.log(greenBright('Invited to an authorised guild. | Data Created'));
});
// When Bot leaves
client.on("guildDelete", guild => {
console.log(``);
// this event triggers when the bot is removed from a guild.
console.log(red(`[GUILD LEFT] ${ guild.name } | [ID] ${ guild.id } | [ (-) MEMBERCOUNT: ${ guild.memberCount }]`));
console.log(``);
/**
* Moves File to backup
*/
function BackUp () {
const guildID = guild.id;
const currentPath = path.join(__dirname, "commands/database/guilds", `${ guildID }.json`);
const destinationPath = path.join(__dirname, "commands/database/backup_guilds", `${ guildID }.json`);
mv(currentPath, destinationPath, function (err) {
if (err) {
console.log(red('Unable to move file path: ' + currentPath + ' to Backup Database\n'));
} else {
console.log(greenBright("Successfully moved the file to Backup Database\n"));
}
});
}
BackUp();
});
// Blacklist User from server
client.on('guildMemberAdd', member => {
if (client.config[member.guild.id].memberJoin === false) return;
const BlacklistedUserID = GBlacklisted.find((u) => u === `${ member.id }`);
const guildID = member.guild.id;
const path = `./commands/database/guilds/${ guildID }.json`;
fs.access(path, fs.F_OK, (err) => {
if (err) {
return console.error(yellowBright('[WARNING]: Databse for Guild ID: ' + guildID + ' has not been set up as an Event has been triggered. Tip: Use [prefix]set for setting up a Database.'));
} else {
const Info = require(`./commands/database/guilds/${ guildID }.json`);
const BlacklistedMember = Info.Data.BlackListedUserIDs.find((user) => user === `${ member.id }`);
const noAccess = new MessageEmbed()
.setTitle('Unauthorised Access To Server: ' + member.guild.name)
.setDescription(`You've been blacklisted in **${ member.guild.name }** and have been denied access of entry.\n
**Owner:** \`${ member.guild.owner.user.tag }\` | <@${ member.guild.owner.id }>
**Member Count:** ${ member.guild.memberCount }\n
*We suggest you DM the owner to be unblacklisted if you wish.*`)
.setTimestamp(Date.now());
const GnoAccess = new MessageEmbed()
.setTitle('Unauthorised Access To Server: ' + member.guild.name)
.setDescription(`You've been globally blacklisted in our Database hence why you cannot join, **${ member.guild.name }** and have been denied access of entry.\n
**Owner:** \`${ member.guild.owner.user.tag }\` | <@${ member.guild.owner.id }>
**Member Count:** ${ member.guild.memberCount }\n
**We suggest you DM the Bot Owner:**\n
**Bot Owner:** <@${ founderId }> | ${ founder }`)
.setTimestamp(Date.now());
if (member.id === BlacklistedUserID) { // Global Blacklisted
member.send(GnoAccess);
setTimeout(function () {
member.ban({
reason: `Blacklisted User`
});
}, 2000); // Waits 2 seconds before banning user
console.log(red(`Global Unauthorised User: ${ member.user.tag } tried joining ${ member.guild.name } and was banned.`));
} else if (member.id === BlacklistedMember) { // Server Blacklist
member.send(noAccess);
setTimeout(function () {
member.ban({
reason: `Globally Blacklisted User`
});
}, 2000); // Waits 2 seconds before banning user
console.log(red(`Unauthorised User: ${ member.user.tag } tried joining ${ member.guild.name } and was banned.`));
} else {
return console.log(greenBright(`Authorised User: ${ member.user.tag } joined ${ member.guild.name }.`));
}
}
});
});
// Fetch Ban
client.on("guildBanAdd", async (guild, user) => {
if (client.config[guild.id].ban === false) return;
const eventsTimestamp = Date.now().toString();
const guildID = guild.id;
const fetchingLogs = await guild.fetchAuditLogs({
limit: 1,
type: "MEMBER_BAN_ADD",
}).catch((err) => {
return console.log(`${ red("[Log Error]: True") }\n${ red("[Log Error Desc.]: " + err) }`);
});
const path = `./commands/database/guilds/${ guildID }.json`;
fs.access(path, fs.F_OK, (err) => {
if (err) {
return console.error(yellowBright('[WARNING]: Databse for Guild ID: ' + guildID + ' has not been set up as an Event has been triggered. Tip: Use [prefix]set for setting up a Database.'));
} else {
if (!fetchingLogs) return console.log(red("[Entries Error] Unable to fetch Entries."));
const banLog = fetchingLogs.entries.first();
if (!banLog) {
return console.log(red(`[Fetch Log Error]: This Log Type: 'MEMBER_BAN_ADD' has not been previously seen before while the 'guildBanAdd' event has been trigerred.`));
} else {
console.log(`\n\n${ grey("======================================") }\n${ yellow("[!] An Event has been fired.") }\n${ yellowBright("[Server]: " + guild.name) }\n${ green("[Event]: 'guildBanAdd'") }\n${ greenBright("[Log Type]: 'MEMBER_BAN_ADD'") }`);
const { executor, target, createdAt, createdTimestamp } = banLog;
console.log(`${ greenBright(`[Event Desc.]: [USER]: ${ target.tag } was banned from the server.`) }`);
console.log(`${ blue(`[Log Timestamp]: ${ createdTimestamp }`) }\n${ blueBright(`[Event Timestamp]: ${ eventsTimestamp }`) }`);
/**
* Checks Whitelisted & Trusted Users Before banning
*/
const guildID = guild.id;
const Info = require(`./commands/database/guilds/${ guildID }.json`);
const WhiteListedUser = Info.Data.WhiteListedUserIDs.find((us) => us === `${ user.id }`);
const Trusted = Info.Data.TrustListedUserIDs.find((u) => u === `${ user.id }`);
const successfulBan = new MessageEmbed()
.setDescription(`**Unauthorised Ban By:** ${ executor.tag } \n**Victim:** ${ target.tag } \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const unsuccessfulBan = new MessageEmbed()
.setDescription(`**Unauthorised Ban By:** ${ executor.tag } \n**Victim:** ${ target.tag } \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Not Given.`)
.setColor("RED")
.setTimestamp(Date.now());
const LogTimeString = createdTimestamp.toString();
const EventExecution = eventsTimestamp;
const logtime = LogTimeString.slice(0, -3);
const eventtime = EventExecution.slice(0, -3);
const logtime2 = LogTimeString.slice(0, -4);
const eventtime2 = EventExecution.slice(0, -4);
if (logtime === eventtime) {
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
guild.members.ban(executor.id, {
reason: `Unauthorised Ban.`
}).then(guild.owner.send(successfulBan).catch((err) => {
return console.log(red("[Owner]: " + guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}))
.then(guild.members.unban(target.id, {
reason: "Victim of an unlawful ban"
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + guild.owner.send(unsuccessfulBan);
});
} else if (logtime2 === eventtime2) {
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
guild.members.ban(executor.id, {
reason: `Unauthorised Ban.`
}).then(guild.owner.send(successfulBan).catch((err) => {
return console.log(red("[Owner]: " + guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}))
.then(guild.members.unban(target.id, {
reason: "Victim of an unlawful ban"
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + guild.owner.send(unsuccessfulBan);
});
} else {
return console.log(`${ grey(`[Event Validity]: False`) }\n${ magenta("[Reason]: Event was triggered but the timestamps didn't match.") }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + target.tag + " (User)") }\n${ grey("======================================") }\n`);
}
}
}
});
});
// Fetch Kick
client.on("guildMemberRemove", async member => {
if (client.config[member.guild.id].kick === false) return;
const eventsTimestamp = Date.now().toString();
const guildID = member.guild.id;
const FetchingLogs = await member.guild.fetchAuditLogs({
limit: 1,
type: "MEMBER_KICK",
}).catch((err) => {
return console.log(`${ red("[Log Error]: True") }\n${ red("[Log Error Desc.]: " + err) }`);
});
if (!FetchingLogs) return console.log(red("[Entries Error] Unable to fetch Entries."));
const kickLog = FetchingLogs.entries.first();
const path = `./commands/database/guilds/${ guildID }.json`;
fs.access(path, fs.F_OK, (err) => {
if (err) {
return console.error(yellowBright('[WARNING]: Databse for Guild ID: ' + guildID + ' has not been set up as an Event has been triggered. Tip: Use [prefix]set for setting up a Database.'));
} else {
if (!kickLog) {
return console.log(red(`[Fetch Log Error]: This Log Type: 'MEMBER_KICK' has not been previously seen before while the 'guildMemberRemove' event has been trigerred.`));
} else {
console.log(`\n\n${ grey("======================================") }\n${ yellow("[!] An Event has been fired.") }\n${ yellowBright("[Server]: " + member.guild.name) }\n${ green("[Event]: 'guildMemberRemove'") }\n${ greenBright("[Log Type]: 'MEMBER_KICK'") }`);
const { executor, target, createdAt, createdTimestamp } = kickLog;
console.log(`${ greenBright(`[Event Desc.]: [USER]: ${ target.tag } was kicked / removed from the server.`) }`);
console.log(`${ blue(`[Log Timestamp]: ${ createdTimestamp }`) }\n${ blueBright(`[Event Timestamp]: ${ eventsTimestamp }`) }`);
/**
* Checks Whitelisted & Trusted Users Before banning
*/
const LogTimeString = createdTimestamp.toString();
const EventExecution = eventsTimestamp;
const logtime = LogTimeString.slice(0, -3);
const eventtime = EventExecution.slice(0, -3);
const logtime2 = LogTimeString.slice(0, -4);
const eventtime2 = EventExecution.slice(0, -4);
const guildID = member.guild.id;
const Info = require(`./commands/database/guilds/${ guildID }.json`);
const WhiteListedUser = Info.Data.WhiteListedUserIDs.find((us) => us === `${ member.id }`);
const Trusted = Info.Data.TrustListedUserIDs.find((u) => u === `${ member.id }`);
const successfulKick = new MessageEmbed()
.setDescription(`**Unauthorised Kick By:** ${ executor.tag } \n**Victim:** ${ target.tag } \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const unsuccessfulKick = new MessageEmbed()
.setDescription(`**Unauthorised Kick By:** ${ executor.tag } \n**Victim:** ${ target.tag } \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Not Given.`)
.setColor("RED")
.setTimestamp(Date.now());
if (logtime === eventtime) {
console.log(`${ grey(`[Event Validity #1]: True`) }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + target.tag + " (User)") }`);
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === member.guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
member.guild.members.ban(executor.id, {
reason: `Unauthorised Kick`
}).then(member.guild.owner.send(successfulKick).catch((err) => {
return console.log(red("[Owner]: " + member.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + member.guild.owner.send(unsuccessfulKick).catch((err) => {
return console.log(red("[Owner]: " + member.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (logtime2 === eventtime2) {
console.log(`${ grey(`[Event Validity #2]: True`) }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + target.tag + " (User)") }`);
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === member.guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
member.guild.members.ban(executor.id, {
reason: `Unauthorised Kick`
}).then(member.guild.owner.send(successfulKick).catch((err) => {
return console.log(red("[Owner]: " + member.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + member.guild.owner.send(unsuccessfulKick).catch((err) => {
return console.log(red("[Owner]: " + member.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else {
return console.log(`${ grey(`[Event Validity]: False`) }\n${ magenta("[Reason]: Event was triggered but the timestamps didn't match.") }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + target.tag + " (User)") }\n${ grey("======================================") }\n`);
}
}
}
});
});
// Channel Create
client.on("channelCreate", async (channel) => {
if (!channel.guild) return;
if (client.config[channel.guild.id].channelCreate === false) return;
const eventsTimestamp = Date.now().toString();
const guildID = channel.guild.id;
const FetchingLogs = await client.guilds.cache.get(channel.guild.id).fetchAuditLogs({
limit: 1,
type: "CHANNEL_CREATE",
}).catch((err) => {
return console.log(`${ red("[Log Error]: True") }\n${ red("[Log Error Desc.]: " + err) }`);
});
if (!FetchingLogs) return console.log(red("[Entries Error] Unable to fetch Entries."));
const path = `./commands/database/guilds/${ guildID }.json`;
fs.access(path, fs.F_OK, (err) => {
if (err) {
return console.error(yellowBright('[WARNING]: Databse for Guild ID: ' + guildID + ' has not been set up as an Event has been triggered. Tip: Use [prefix]set for setting up a Database.'));
} else {
const ChannelLog = FetchingLogs.entries.first();
if (!ChannelLog) {
return console.log(red(`[Fetch Log Error]: This Log Type: 'CHANNEL_CREATE' has not been previously seen before while the 'channelCreate' event has been trigerred.`));
} else {
console.log(`\n\n${ grey("======================================") }\n${ yellow("[!] An Event has been fired.") }\n${ yellowBright("[Server]: " + channel.guild.name) }\n${ green("[Event]: 'channelCreate'") }\n${ greenBright("[Log Type]: 'CHANNEL_CREATE'") }`);
console.log(`${ greenBright(`[Event Desc.]: [CHANNEL]: "${ channel.name }" has been created in the server`) }`);
const { executor, createdAt, createdTimestamp } = ChannelLog;
console.log(`${ blue(`[Log Timestamp]: ${ createdTimestamp }`) }\n${ blueBright(`[Event Timestamp]: ${ eventsTimestamp }`) }`);
const successfulBanText = new MessageEmbed()
.setDescription(`**Unauthorised Channel Created By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanCategory = new MessageEmbed()
.setDescription(`**Unauthorised Category Created By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanVoice = new MessageEmbed()
.setDescription(`**Unauthorised Voice Channel Created By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanStore = new MessageEmbed()
.setDescription(`**Unauthorised Store Channel Created By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanNews = new MessageEmbed()
.setDescription(`**Unauthorised Announcement Channel Created By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanUnkownChannel = new MessageEmbed()
.setDescription(`**Unauthorised Unkown Channel Type Created By:** ${ executor.tag } \n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const unsuccessfulBan = new MessageEmbed()
.setDescription(`**Unauthorised Channel Created By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Not Given.`)
.setColor("RED")
.setTimestamp(Date.now());
/**
* Checks Whitelisted & Trusted Users Before banning
*/
const guildID = channel.guild.id;
const Info = require(`./commands/database/guilds/${ guildID }.json`);
const WhiteListedUser = Info.Data.WhiteListedUserIDs.find((us) => us === `${ executor.id }`);
const Trusted = Info.Data.TrustListedUserIDs.find((u) => u === `${ executor.id }`);
const LogTimeString = createdTimestamp.toString();
const EventExecution = eventsTimestamp;
const logtime = LogTimeString.slice(0, -3);
const eventtime = EventExecution.slice(0, -3);
const logtime2 = LogTimeString.slice(0, -4);
const eventtime2 = EventExecution.slice(0, -4);
if (logtime === eventtime) {
console.log(`${ grey(`[Event Validity #1]: True`) }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + channel.name + " (Channel)") }`);
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === channel.guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (channel.type === "text") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Channel Created`
}).then(channel.guild.owner.send(successfulBanText).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "category") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Category Created`
}).then(channel.guild.owner.send(successfulBanCategory).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "voice") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Voice Channel Created`
}).then(channel.guild.owner.send(successfulBanVoice).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "store") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Store Channel Created`
}).then(channel.guild.owner.send(successfulBanStore).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "news") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Announcement Channel Created`
}).then(channel.guild.owner.send(successfulBanNews).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Unknown Channel Type Created`
}).then(channel.guild.owner.send(successfulBanUnkownChannel).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
}
} else if (logtime2 === eventtime2) {
console.log(`${ grey(`[Event Validity #2]: True`) }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + channel.name + " (Channel)") }`);
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === channel.guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (channel.type === "text") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Channel Created`
}).then(channel.guild.owner.send(successfulBanText).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "category") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Category Created`
}).then(channel.guild.owner.send(successfulBanCategory).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "voice") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Voice Channel Created`
}).then(channel.guild.owner.send(successfulBanVoice).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "store") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Store Channel Created`
}).then(channel.guild.owner.send(successfulBanStore).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "news") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Announcement Channel Created`
}).then(channel.guild.owner.send(successfulBanNews).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Unknown Channel Type Created`
}).then(channel.guild.owner.send(successfulBanUnkownChannel).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
}
} else {
return console.log(`${ grey(`[Event Validity]: False`) }\n${ magenta("[Reason]: Event was triggered but the timestamps didn't match.") }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + channel.id + " (Channel ID)") }\n${ grey("======================================") }\n`);
}
}
}
});
});
// Channel Delete
client.on("channelDelete", async (channel) => {
if (client.config[channel.guild.id].channelDelete === false) return;
const eventsTimestamp = Date.now().toString();
if (!channel.guild) return;
const guildID = channel.guild.id;
const FetchingLogs = await client.guilds.cache.get(channel.guild.id).fetchAuditLogs({
limit: 1,
type: "CHANNEL_DELETE",
}).catch((err) => {
return console.log(`${ red("[Log Error]: True") }\n${ red("[Log Error Desc.]: " + err) }`);
});
if (!FetchingLogs) return console.log(red("[Entries Error] Unable to fetch Entries."));
const path = `./commands/database/guilds/${ guildID }.json`;
fs.access(path, fs.F_OK, (err) => {
if (err) {
return console.error(yellowBright('[WARNING]: Databse for Guild ID: ' + guildID + ' has not been set up as an Event has been triggered. Tip: Use [prefix]set for setting up a Database.'));
} else {
const ChannelLog = FetchingLogs.entries.first();
if (!ChannelLog) {
return console.log(red(`[Fetch Log Error]: This Log Type: 'CHANNEL_DELETE' has not been previously seen before while the 'channelDelete' event has been trigerred.`));
} else {
console.log(`\n\n${ grey("======================================") }\n${ yellow("[!] An Event has been fired.") }\n${ yellowBright("[Server]: " + channel.guild.name) }\n${ green("[Event]: 'channelDelete'") }\n${ greenBright("[Log Type]: 'CHANNEL_DELETE'") }`);
console.log(`${ greenBright(`[Event Desc.]: [CHANNEL]: "${ channel.name }" has been deleted in the server`) }`);
const { executor, createdAt, createdTimestamp } = ChannelLog;
console.log(`${ blue(`[Log Timestamp]: ${ createdTimestamp }`) }\n${ blueBright(`[Event Timestamp]: ${ eventsTimestamp }`) }`);
const successfulBanText = new MessageEmbed()
.setDescription(`**Unauthorised Channel Deleted By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanCategory = new MessageEmbed()
.setDescription(`**Unauthorised Category Deleted By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanVoice = new MessageEmbed()
.setDescription(`**Unauthorised Voice Channel Deleted By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanStore = new MessageEmbed()
.setDescription(`**Unauthorised Store Channel Deleted By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanNews = new MessageEmbed()
.setDescription(`**Unauthorised Announcement Channel Deleted By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const successfulBanUnkownChannel = new MessageEmbed()
.setDescription(`**Unauthorised Unkown Channel Type Deleted By:** ${ executor.tag } \n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Ban.`)
.setColor(0x36393E)
.setTimestamp(Date.now());
const unsuccessfulBan = new MessageEmbed()
.setDescription(`**Unauthorised Channel Deleted By:** ${ executor.tag }\n\n**Channel:** \`${ channel.name }\` \n**Channel ID:** ||${ channel.id }|| \n**Time:** ${ createdAt.toDateString() } \n**Sentence:** Not Given.`)
.setColor("RED")
.setTimestamp(Date.now());
/**
* Checks Whitelisted & Trusted Users Before banning
*/
const guildID = channel.guild.id;
const Info = require(`./commands/database/guilds/${ guildID }.json`);
const WhiteListedUser = Info.Data.WhiteListedUserIDs.find((us) => us === `${ executor.id }`);
const Trusted = Info.Data.TrustListedUserIDs.find((u) => u === `${ executor.id }`);
const LogTimeString = createdTimestamp.toString();
const EventExecution = eventsTimestamp;
const logtime = LogTimeString.slice(0, -3);
const eventtime = EventExecution.slice(0, -3);
const logtime2 = LogTimeString.slice(0, -4);
const eventtime2 = EventExecution.slice(0, -4);
if (logtime === eventtime) {
console.log(`${ grey(`[Event Validity #1]: True`) }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + channel.name + " (Channel)") }`);
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === channel.guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (channel.type === "text") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Channel Deleted`
}).then(channel.guild.owner.send(successfulBanText).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "category") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Category Deleted`
}).then(channel.guild.owner.send(successfulBanCategory).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "voice") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Voice Channel Deleted`
}).then(channel.guild.owner.send(successfulBanVoice).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "store") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Store Channel Deleted`
}).then(channel.guild.owner.send(successfulBanStore).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "news") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Announcement Channel Deleted`
}).then(channel.guild.owner.send(successfulBanNews).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Unknown Channel Type Deleted`
}).then(channel.guild.owner.send(successfulBanUnkownChannel).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
}
} else if (logtime2 === eventtime2) {
console.log(`${ grey(`[Event Validity #2]: True`) }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + channel.name + " (Channel)") }`);
if (executor.id === client.user.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === channel.guild.owner.id) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (executor.id === WhiteListedUser || Trusted) return console.log(`${ magentaBright(`[Action Type]: AUTHORISED`) }\n${ grey("======================================") }\n`);
if (channel.type === "text") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Channel Deleted`
}).then(channel.guild.owner.send(successfulBanText).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "category") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Category Deleted`
}).then(channel.guild.owner.send(successfulBanCategory).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "voice") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Voice Channel Deleted`
}).then(channel.guild.owner.send(successfulBanVoice).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "store") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Store Channel Deleted`
}).then(channel.guild.owner.send(successfulBanStore).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else if (channel.type === "news") {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Announcement Channel Deleted`
}).then(channel.guild.owner.send(successfulBanNews).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
} else {
channel.guild.member(executor.id).ban({
reason: `Unauthorised Unknown Channel Type Deleted`
}).then(channel.guild.owner.send(successfulBanUnkownChannel).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
}).then(() => {
console.log(`${ redBright("[Trial]: True") }\n${ red("[Sentence]: Ban") }\n${ grey("======================================") }\n`);
})).catch((err) => {
return console.log(`${ redBright("[Trial]: False") }\n${ red("[Sentence]: No Sentence Given") }\n${ magentaBright("[Sentence Error]: " + err) }\n${ grey("======================================") }\n`) + channel.guild.owner.send(unsuccessfulBan).catch((err) => {
return console.log(red("[Owner]: " + channel.guild.owner.user.tag + " could not be messaged. [Message Error Desc.]: " + err));
});
});
}
} else {
return console.log(`${ grey(`[Event Validity]: False`) }\n${ magenta("[Reason]: Event was triggered but the timestamps didn't match.") }\n${ cyan("[Executor]: " + executor.tag) }\n${ cyanBright("[Target]: " + channel.id + " (Channel ID)") }\n${ grey("======================================") }\n`);
}
}
}
});