-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
824 lines (817 loc) · 34.8 KB
/
app.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
const projname = "BTS Bot"
const colours = require('colors');
const Discord = require("discord.js");
const client = new Discord.Client();
const conf = require("./conf.json");
const rolenames = require("./roles.json");
var safe = false
const removeblacklist = ['456855204340563999', '725771238416449646', '155149108183695360', '189702078958927872', '234395307759108106', '389361997356990465']
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} Attempting to connect to Discord\'s API...`);
client.on("ready", () => {
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} Successfully connected to Discord's API!\n${projname} will now list who ran what command in which server and channel at what time.\n\Prefix: ${conf.prefix}\n\Status: ${conf.ostatus}\n\Playing status: ${conf.pstatus}`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${projname} has started.`,
},
}));
client.user.setPresence({ activity: { name: conf.pstatus }, status: conf.ostatus })
.catch(console.error);
});
client.on('error', (error) => {
console.trace(`${colours.cyan(`${new Date()}`)} - ${'WARN:'.yellow} ${error}`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `${new Date()} - WARN: ${JSON.stringify(error).toString().slice(0, 1994)}`,
},
}).catch(O_o=>{}))
});
client.on("guildMemberAdd", (member) => {
var safe = "ambiguous"
for (token in conf.bannedusernametokens) {
if (member.user.username.toLowerCase().includes(token)) {
member.ban({reason:"A part of the user's username is listed as a banned token"})
} else {
var safe = true
}
}
if (safe == true && safe != "ambiguous") {
if (member.user.bot) {
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${member.user.tag} (${member.id}) was added to ${member.guild.name} (${member.guild.id}). The "Bots" role was assigned automatically`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${member.user.tag} (${member.id}) was added to ${member.guild.name} (${member.guild.id}). The "Bots" role was assigned automatically`,
},
}).catch(O_o=>{}))
if (member.guild.id == conf.btsid) {
member.guild.members.fetch(member.id).then(gm => gm.roles.add(conf.btsbotsroleid, "Member is a bot"))
}
if (member.guild.id == conf.btst3id) {
member.guild.members.fetch(member.id).then(gm => gm.roles.add(conf.btst3botsroleid, "Member is a bot"))
}
}
if (!member.user.bot) {
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${member.user.tag} (${member.id}) joined ${member.guild.name} (${member.guild.id}). The provision of the "Bots" role was suppressed`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${member.user.tag} (${member.id}) joined ${member.guild.name} (${member.guild.id}). The provision of the "Bots" role was suppressed`,
},
}).catch(O_o=>{}))
client.users.fetch(member.id)
.then(user => user.send({
embed: {
color: 0x9b59b6,
description: `Welcome to Bot Testing Server! Should you find yourself banned, you can appeal this decision [here](${conf.appeallink})`,
},
}).catch(O_o=>{}))
}
}
})
client.on("message", async (message) => {
if (!message.author.bot && message.channel.type == "dm") {
var attach = (message.attachments.array())
let files = []
if (message.content == "") {
var msgcontent = "(empty)"
} else var msgcontent = message.content
if (attach) {
for (let file of attach) {
files.push(file.url)
}
}
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${message.author.tag} (${message.author.id}) sent a modmail message with the content "${message.content}" in ${message.channel.id}.`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${message.author.tag} (${message.author.id}) sent a modmail message with the content "${message.content}" in ${message.channel.id}.`,
},
}).catch(O_o=>{}))
message.channel.send({
embed: {
color: 0x9b59b6,
description: `Thank you for your message! We will reply as soon as possible.`,
},
})
client.channels.fetch(conf.modmailid)
.then(channel => channel.send({files: files, embed: {
color: 0xE67E22,
author: {
name: message.author.tag,
icon_url: message.author.avatarURL()
},
title: "A user has sent a modmail message",
description: `To reply to this message, use ${conf.prefix}reply ${message.author.id} <message>`,
fields: [
{
name: "User (and their ID)",
value: message.author.tag + " (" + message.author.id + ")"
},
{
name: "Message",
value: msgcontent
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL(),
text: "This message is confidential. Unauthorised disclosure may result in sanctions including warnings and potentially revocation of privileges."
}
}
}))
}
if (!message.author.bot && message.channel.type != "dm" && !message.member.roles.cache.has(rolenames["bot owners"]) && !message.member.roles.cache.has(conf.btst3botownersroleid)) {
if (message.guild.id == conf.btsid) {
var botownersid = rolenames["bot owners"]
} else var botownersid = conf.btst3botownersroleid
if ((message.content.toLowerCase().includes("my bot") || message.content.toLowerCase().includes("i own a bot") || (message.content.toLowerCase().includes("i own <@") && message.content.toLowerCase().includes(">")) || (message.content.toLowerCase().includes("i own <@!") && message.content.toLowerCase().includes(">"))) && !message.content.toLowerCase().includes("\"")) {
message.member.guild.members.fetch(message.author.id).then(gm => gm.roles.add(botownersid, "Member sent a message that implies they own a bot"))
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${message.author.tag} (${message.author.id}) said ${message.content} in ${message.guild.name} (${message.guild.id}), #${message.channel.name} (${message.channel.id}). Because this message implies they own a bot, they were given the "Bot Owners" role.`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${message.author.tag} (${message.author.id}) said ${message.content} in ${message.guild.name} (${message.guild.id}), #${message.channel.name} (${message.channel.id}). Because this message implies they own a bot, they were given the "Bot Owners" role.`,
},
}).catch(O_o=>{}))
}
}
if (message.channel.id == conf.pollchannelid) {
message.react("👍")
await message.react("👎")
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${message.author.tag} (${message.author.id}) sent ${message.content} in ${message.guild.name} (${message.guild.id}), #${message.channel.name} (${message.channel.id}). Because this message was sent in #${message.channel.name}, the 👍 and 👎 reactions were automatically added.`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${message.author.tag} (${message.author.id}) sent ${message.content} in ${message.guild.name} (${message.guild.id}), #${message.channel.name} (${message.channel.id}). Because this message was sent in #${message.channel.name}, the 👍 and 👎 reactions were automatically added.`,
},
}).catch(O_o=>{}))
}
});
client.on("message", async (message) => {
if (!message.content.startsWith(conf.prefix) || message.author.bot) return;
if (message.channel.type === 'dm') return;
const args = message.content.slice(conf.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command == "help" || command == "report" || command == "request" || command == "role" || command == "announce" || command == "stop" || command == "restart" || command == "reply" || command == "reachout" || command == "fixstatus" || command == "remove") {
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${message.author.tag} (${message.author.id}) ran ${message.content} in ${message.guild.name} (${message.guild.id}), #${message.channel.name} (${message.channel.id}).`);
client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${message.author.tag} (${message.author.id}) ran ${message.content} in ${message.guild.name} (${message.guild.id}), #${message.channel.name} (${message.channel.id}).`,
},
}).catch(O_o=>{}))
}
if (message.channel.id != conf.btsbotrequestsid && message.channel.id != conf.btst3botrequestsid && message.channel.id != conf.modmailid && message.channel.id != conf.announcementfactoryid) {
if (command == "help") {
var help = "**" + conf.prefix + "help** - Displays this message\n\**" + conf.prefix + "role** - Assigns, lists and remove self-assignable roles (AKA SARs) (toggle, run " + conf.prefix + "role list to see all SARs)\n\**" + conf.prefix + "construct** - Constructs an OAuth2 URL from the given ID. If the user is in the server, constructs generic URL, else consructs URL specific to this server"
if (message.member.roles.cache.has(conf.announcersroleid)) {
var help = help + "\n\**" + conf.prefix + "announce** - If used in <#" + conf.announcementfactoryid + ">, sends an announcement to <#" + conf.announcementsid + ">"
}
if (!message.member.hasPermission("MANAGE_GUILD")) {
var help = help + "\n\**" + conf.prefix + "request** - Requests a bot to be added to this server"
}
if (!message.member.roles.cache.has(conf.moderatorsroleid)) {
var help = help + "\n\**" + conf.prefix + "report** - Reports a user, ensure to add proof in your reasoning"
}
if (message.member.roles.cache.has(conf.moderatorsroleid)) {
var help = help + "\n\**" + conf.prefix + "reply** - Replies to specified user in modmail\n\**" + conf.prefix + "reachout** Reaches out to specified user using modmail"
}
if (message.member.hasPermission("MANAGE_GUILD")) {
var help = help + "\n\**" + conf.prefix + "remove** - Removes a bot from the server"
}
if (message.author.id == conf.OwnerID) {
var help = help + "\n\**" + conf.prefix + "stop** - Stops the bot\n\**" + conf.prefix + "restart** - Restarts the bot\n\**" + conf.prefix + "fixstatus** - Fixes the status in the case that SOMEONE ever breaks it"
}
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Help",
description: help
}
})
}
if (command == "stop") {
if (message.author.id == conf.OwnerID) {
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Stopping...",
description: "STOP ---- HA- I mean BTSBot was stopped."
}
})
await client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: ${projname} was stopped.`,
},
}))
await client.destroy()
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} ${projname} was stopped.`)
process.exit()
}
else {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You do not have sufficient permissions to run this command. You need the \`Owner of ${projname}\` permission.`,
},
});
}
}
if (command == "restart") {
if (message.author.id == conf.OwnerID) {
if (client.user.id == "456855204340563999") {
var emoji = "<:PHBlowTestSuccessful:409711288504287233>"
} else {
var emoji = ""
}
message.channel.send({
embed: {
color: 0x9b59b6,
title: 'Success! ' + emoji,
description: 'Restarting...',
},
});
await client.channels.fetch(conf.logchannelID)
.then(channel => channel.send({
embed: {
color: 0x9b59b6,
description: `${new Date()} - INFO: Restarting...`,
},
})).catch(O_o=>{});
client.destroy();
await client.login(conf.token);
console.log(`${colours.cyan(`${new Date()}`)} - ${'INFO:'.green} Restarting...`);
client.emit('ready')
}
else {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You do not have sufficient permissions to run this command. You need the \`Owner of ${projname}\` permission.`,
},
});
}
}
if (command == "fixstatus") {
if (message.author.id == conf.OwnerID) {
if (client.user.id == "456855204340563999") {
var emoji = "<:PHBlowTestSuccessful:409711288504287233>"
} else {
var emoji = ""
}
message.channel.send({
embed: {
color: 0x9b59b6,
title: 'Success! ' + emoji,
description: 'Fixing status...',
},
});
client.emit('ready')
}
else {
message.author.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You do not have sufficient permissions to run this command. You need the \`Owner of ${projname}\` permission.`,
},
});
}
}
if (command == "report" && message.channel.id != conf.btsbotrequestsid && message.channel.id != conf.announcementfactoryid && message.channel.id != conf.reportschannelid && message.channel.id != conf.modmailid && message.channel.id != conf.btst3botrequestsid) {
let userid = args[0];
let reason = args.slice(1).join(" ");
var attach = (message.attachments.array())
let files = []
if (attach) {
for (let file of attach) {
files.push(file.url)
}
}
if (message.guild.members.cache.some(user => user.id === userid) && reason && message.author.id != userid && !message.member.roles.cache.has(conf.moderatorsroleid) && !message.member.roles.cache.has(conf.btst3moderatorsroleid)) {
client.channels.fetch(conf.reportschannelid)
.then(channel => channel.send({files: files, embed: {
color: 0xe74c3c,
author: {
name: message.author.tag,
icon_url: message.author.avatarURL()
},
title: "A new report has been made: YOUR ATTENTION IS REQUIRED",
description: "You can deal with this report in <#" + conf.privcmdschannelid + ">\n\Upon dealing with this report, please react to it with ✅ so we all know it's been dealt with",
fields: [{
name: "Server",
value: message.guild.name
},
{
name: "Reporting user (and their ID)",
value: message.author.tag + " (" + message.author.id + ")"
},
{
name: "User and their ID being reported",
value: userid + " - <@" + userid + ">"
},
{
name: "Reason",
value: reason
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL(),
text: "This report is confidential. Unauthorised disclosure may result in sanctions including warnings and potentially revocation of privileges."
}
}}))
client.users.fetch(message.author.id)
.then(user => user.send({embed: {
color: 0x9b59b6,
title: "Thank you",
description: "Thank you for reporting <@" + userid + ">. Our staff team will review it as soon as possible. Thank you for your contributions to keep Bot Testing Server the way it should be - decent, friendly and intuitive.\n\Please do not reply to this message."
}}))
}
if (message.member.roles.cache.has(conf.moderatorsroleid) || message.member.roles.cache.has(conf.btst3moderatorsroleid)) {
client.users.fetch(message.author.id)
.then(user => user.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You do not have sufficient permissions to run this command. You have the \`Moderators\` permission.`,
},
}));
}
if ((!message.guild.members.cache.some(user => user.id === userid)) && !(message.member.roles.cache.has(conf.moderatorsroleid) || message.member.roles.cache.has(conf.btst3moderatorsroleid)) && reason) {
client.users.fetch(message.author.id)
.then(user => user.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `This user could not be found. Are they in this server? Are you ensuring that you do not mention them (which attracts their attention) when running the command?`,
},
}));
}
if (!reason && !message.member.roles.cache.has(conf.moderatorsroleid)) {
client.users.fetch(message.author.id)
.then(user => user.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <user ID> <reason>\n\Example: ${conf.prefix}${command} 224606298673512458 Advertising`,
},
}));
}
if (userid == message.author.id && !message.member.roles.cache.has(conf.moderatorsroleid)) {
client.users.fetch(message.author.id)
.then(user => user.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You cannot report yourself!`,
},
}));
}
await message.delete({ timeout: 500 })
}
if (command == "role") {
let role = args.slice(0).join(" ");
var lowercaserole = role.toLowerCase()
if (!role) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <role name>\n\Example: ${conf.prefix}${command} bot owners`,
},
});
}
if (message.guild.id == conf.btsid) {
if (role && rolenames[lowercaserole] == null && role.toLowerCase() != "tbmping" && role.toLowerCase() != "list") {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You cannot assign that role to yourself.`,
},
});
if (role == "tbmping" && !message.member.roles.cache.has(conf.tbmroleid)) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You cannot assign that role to yourself.`,
},
});
}
}
if (role == "list") {
var rolelist = "Bot Owners\nred\nbrown\norange\nyellow\ngreen\nsky blue\nlight blue\nblue\npurple\nmagenta\npeach\ngrey\nblack\nwhite"
if (message.member.roles.cache.has(conf.tbmroleid)) {
var rolelist = rolelist + "\ntbmping"
}
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Self-assignable role list",
description: rolelist
}
})
}
if (rolenames[lowercaserole] != null) {
if (!message.member.roles.cache.has(rolenames[lowercaserole])) {
message.guild.members.fetch(message.author.id).then(gm => gm.roles.add(rolenames[lowercaserole], "User self-assigned role"))
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Success!",
description: "You have successfully self-assigned that role"
}
})
}
if (message.member.roles.cache.has(rolenames[lowercaserole])) {
message.guild.members.fetch(message.author.id).then(gm => gm.roles.remove(rolenames[lowercaserole], "User self-removed role"))
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Success!",
description: "You have successfully removed that role"
}
})
}
}
if (role.toLowerCase() == "tbmping" && message.member.roles.cache.has(conf.tbmroleid)) {
if (!message.member.roles.cache.has(conf.tbmpingroleid)) {
message.guild.members.fetch(message.author.id).then(gm => gm.roles.add(conf.tbmpingroleid, "User self-assigned role"))
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Success!",
description: "You have successfully self-assigned that role"
}
})
}
if (message.member.roles.cache.has(conf.tbmpingroleid)) {
message.guild.members.fetch(message.author.id).then(gm => gm.roles.remove(conf.tbmpingroleid, "User self-removed role"))
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Success!",
description: "You have successfully removed that role"
}
})
}
}
}
if (message.guild.id == conf.btst3id) {
if (role && role.toLowerCase() != "bot owners" && role.toLowerCase() != "list") {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You cannot assign that role to yourself.`,
},
});
}
if (role == "list") {
var rolelist = "Bot Owners"
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Self-assignable role list",
description: rolelist
}
})
}
if (role.toLowerCase() == "bot owners") {
if (!message.member.roles.cache.has(conf.btst3botownersroleid)) {
message.guild.members.fetch(message.author.id).then(gm => gm.roles.add(conf.btst3botownersroleid, "User self-assigned role"))
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Success!",
description: "You have successfully self-assigned that role"
}
})
}
if (message.member.roles.cache.has(conf.btst3botownersroleid)) {
message.guild.members.fetch(message.author.id).then(gm => gm.roles.remove(conf.btst3botownersroleid, "User self-removed role"))
message.channel.send({
embed: {
color: 0x9b59b6,
title: "Success!",
description: "You have successfully removed that role"
}
})
}
}
}
}
}
if (command == "request") {
if ((message.channel.id == conf.btsbotrequestsid || message.channel.id == conf.btst3botrequestsid)) {
let clientid = args[0];
let ignore = args.slice(1).join(" ")
if (!clientid && !message.member.hasPermission('MANAGE_GUILD')) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <client ID>\n\Example: ${conf.prefix}${command} 397489174791585795`,
},
});
}
if (message.guild.members.cache.some(user => user.id === clientid) && !message.member.hasPermission('MANAGE_GUILD')) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `The bot you are requesting to add is already in this server!`,
},
});
}
if (message.member.hasPermission('MANAGE_GUILD')) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You do not have sufficient permissions to run this command. You have the \`MANAGE_GUILD\` permission.`,
},
});
}
if (!message.guild.members.cache.some(user => user.id === clientid) && clientid && !message.member.hasPermission('MANAGE_GUILD')) {
const banlist = await message.guild.fetchBans();
const checkban = await message.guild.fetchBan(clientid).catch(O_o=>{})
if (checkban == undefined) {
var banned = false
} else var banned = true
if (banned == true) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `The bot that you are requesting is banned from this guild`,
},
});
} else {
client.channels.fetch(conf.botaddingid)
.then(channel => channel.send("<@&" + conf.tbmpingroleid +">", {embed: {
color: 0x2ecc71,
author: {
name: message.author.tag,
icon_url: message.author.avatarURL()
},
title: "A bot has been requested!",
description: "Upon being added, it will be automatically assigned roles",
fields: [{
name: "Server",
value: message.guild.name
},
{
name: "Requesting user (and their ID)",
value: message.author.tag + " (" + message.author.id + ")"
},
{
name: "OAuth2 link",
value: "[" + clientid + "](https://discord.com/oauth2/authorize?scope=bot&guild_id=" + message.guild.id + "&disable_guild_select=true&client_id=" + clientid + ")"
},
{
name: "Additional information",
value: "After adding the bot, go ahead and tell <@!" + message.author.id + "> in <#" + message.channel.id + "> that their bot was added!"
}],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL(),
text: projname
}
}}));
message.channel.send({embed: {
title: "Success!",
description: "The bot you requested has been forwarded to our trusted bot managers",
color: 0x9b59b6
}})
}
}
}
}
if (command == "construct") {
var genericurl = ""
if ((message.channel.id == conf.btsbotrequestsid || message.channel.id == conf.btst3botrequestsid)) {
let clientid = args[0];
let ignore = args.slice(1).join(" ")
if (!clientid) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <client ID>\n\Example: ${conf.prefix}${command} 397489174791585795`,
},
});
}
if (!message.member.hasPermission('MANAGE_GUILD')) {
var url = "https://discord.com/oauth2/authorize?scope=bot&client_id=" + clientid
} else if (!message.guild.members.cache.some(user => user.id === clientid) && message.member.hasPermission('MANAGE_GUILD')) {
var url = "https://discord.com/oauth2/authorize?scope=bot&guild_id=" + message.guild.id + "&disable_guild_select=true&client_id=" + clientid
var genericurl = "\n\nIf your intention was to generate a bot invite for another server, the invite you requested can be found [here](https://discord.com/oauth2/authorize?scope=bot&client_id=" + clientid + ")"
}
message.channel.send({embed: {
title: "Success!",
description: `The link you requested can be found [here](${url}) ${genericurl}`,
color: 0x9b59b6
}})
}
}
if ((command == "reply" || command == "reachout") && message.channel.id == conf.modmailid) {
let userid = args[0];
let msg = args.slice(1).join(" ");
if (command == "reply") {
var title = "A moderator has replied to your message!"
}
if (command == "reachout") {
var title = "A moderator has sent you a message!"
}
if (userid == message.author.id) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You cannot reach out to yourself!`,
},
});
}
if (!client.users.cache.some(user => user.id === userid) || client.users.cache.get(userid).bot) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `This user could not be found. Are they in this server or BTSt3? Are you ensuring that you do not mention them when running the command? Is this user a human?`,
},
});
}
if (!msg) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <user ID> <message>\n\Example: ${conf.prefix}${command} 224606298673512458 Hello!`,
},
});
} if (userid != message.author.id && msg && client.users.cache.some(user => user.id === userid && !client.users.cache.get(userid).bot)) {
client.users.fetch(userid)
.then(user => user.send({embed: {
color: 0x9b59b6,
author: {
name: message.author.tag,
icon_url: message.author.avatarURL()
},
title: title,
description: "You can reply to this message",
fields: [{
name: "Moderator (and their ID)",
value: message.author.tag + " (" + message.author.id + ")"
},
{
name: "Message",
value: msg
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL(),
text: projname
}
}}))
message.channel.send({embed: {
color: 0x9b59b6,
title: "Success!",
description: "Successfully messaged <@" + userid + ">"
}})
}
}
if (command == "announce" && message.channel.id == conf.announcementfactoryid) {
var attach = (message.attachments.array())
let files = []
if (attach) {
for (let file of attach) {
files.push(file.url)
}
}
let pingtype = args[0];
let msg = args.slice(1).join(" ");
if (!msg || (pingtype != "here" && pingtype != "everyone" && pingtype != "noping")) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <everyone/here/noping> <message>\n\Example: ${conf.prefix}${command} noping ily guys`,
},
});
}
if (pingtype == "here") {
var pt = "@here"
}
if (pingtype == "everyone") {
var pt = "@everyone"
}
if (pingtype == "noping") {
var pt = ""
}
if (msg && (pingtype == "here" || pingtype == "everyone" || pingtype == "noping")) {
client.channels.fetch(conf.announcementsid)
.then(channel => channel.send(pt, {files: files, embed: {
color: 0x9b59b6,
author: {
name: message.author.tag,
icon_url: message.author.avatarURL()
},
title: "Announcement",
fields: [{
name: "Message",
value: msg
}],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL(),
text: projname
}
}}))
message.channel.send({embed: {
color: 0x9b59b6,
title: "Success!",
description: "Successfully posted announcement in <#" + conf.announcementsid + ">!"
}})
}
}
if (command == "remove" && message.guild.me.hasPermission('SEND_MESSAGES') && message.channel.id != conf.modmailid && message.channel.id != conf.announcementfactoryid) {
let clientid = args[0];
let ignore = args.slice(1).join(" ")
if (!clientid && message.member.hasPermission('MANAGE_GUILD')) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You are missing arguments.\n\Usage: ${conf.prefix}${command} <client ID>\n\Example: ${conf.prefix}${command} 397489174791585795`,
},
});
}
if (!message.guild.members.cache.some(user => user.id === clientid) && message.member.hasPermission('MANAGE_GUILD') && clientid) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `The bot you specified is not in this server.`,
},
});
}
if (!message.member.hasPermission('MANAGE_GUILD')) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You do not have sufficient permissions to run this command. You need the \`MANAGE_GUILD\` permission.`,
},
});
}
if (message.guild.members.cache.some(user => user.id === clientid) && message.member.hasPermission('MANAGE_GUILD') && !client.users.cache.get(clientid).bot) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `The user you specified is not a bot.`,
},
});
}
if (message.guild.members.cache.some(user => user.id === clientid) && message.member.hasPermission('MANAGE_GUILD') && client.users.cache.get(clientid).bot) {
if (removeblacklist.includes(clientid)) {
message.channel.send({
embed: {
color: 0xff0000,
title: 'Error',
description: `You cannot remove this bot.`,
},
});
} else {
message.channel.send({
embed: {
color: 0x9b59b6,
title: 'Success!',
description: `Successfully removed bot with ID ${clientid}!`,
},
})
message.guild.member(clientid).kick('Removal was requested by ' + message.author.tag + ', a trusted bot manager')
}
}
}
})
client.login(conf.token)