This repository has been archived by the owner on Oct 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.js
1354 lines (1188 loc) · 57.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
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
const Discord = require("discord.js");
const settings = require("./settings.json");
const moment = require("moment");
var client = new Discord.Client();
// Fortunes for 8ball command
var fortunes = [
"`Yes`",
"`No`",
"`Maybe`",
"`Ask again`",
"`Sometimes`",
"`Okay`",
"`HELL NO`",
"`FUCK YEAH`",
"`no no no`"
];
// Functions when the bot is online
client.on("ready", function() {
var clientonmessage = `
------------------------------------------------------
> Logging in...
------------------------------------------------------
Logged in as ${client.user.tag}
Working on ${client.guilds.size} servers!
${client.channels.size} channels and ${client.users.size} users cached!
I am logged in and ready to roll!
LET'S GO!
------------------------------------------------------
----------Bot created by Blue Malgeran#3106-----------
------------------------------------------------------
-----------------Bot's commands logs------------------`
console.log(clientonmessage);
//The default game.
//client.user.setActivity(`${client.guilds.size} servers | ${settings.botPREFIX}help`, { type: settings.statusTYPE });
// Cool interval loop for the bot's game.
let statusArray = [
`${settings.botPREFIX}help | ${client.guilds.size} servers!`,
`${settings.botPREFIX}help | ${client.channels.size} channels!`,
`${settings.botPREFIX}help | ${client.users.size} users!`
];
setInterval(function() {
client.user.setActivity(`${statusArray[~~(Math.random() * statusArray.length)]}`, { type: settings.statusTYPE });
}, 100000);
});
// Logs of the bot joined a server and changed the game of the bot
client.on("guildCreate", guild => {
const logsServerJoin = client.channels.get(settings.logsChannelID);
console.log(`The bot just joined to ${guild.name}, Owned by ${guild.owner.user.tag}`);
logsServerJoin.send(`The bot just joined to ${guild.name}, Owned by ${guild.owner.user.tag}`);
var guildMSG = guild.channels.find('name', 'general');
if (guildMSG) {
guildMSG.send(`
Hello there! My original name is \`NotABot\`!\n\
This bot created by **Blue Malgeran#3106**\n\
For more info type \`${settings.botPREFIX}help\`!\n\
\`NotABot - Official Server:\` https://discord.gg/KugMg6K`);
} else {
return;
}
});
// Logs of the bot leaves a server and changed the game of the bot
client.on("guildDelete", guild => {
const logsServerLeave = client.channels.get(settings.logsChannelID);
console.log(`The bot has been left ${guild.name}, Owned by ${guild.owner.user.tag}`);
logsServerLeave.send(`The bot has been left ${guild.name}, Owned by ${guild.owner.user.tag}`);
});
// Message function
client.on("message", async message => {
if (message.author.equals(client.user)) return;
if (!message.content.startsWith(settings.botPREFIX)) return;
if (message.author.bot) return;
const logsCommands = client.channels.get(settings.logsChannelID);
//Disables commands in a private chat
if (message.channel.type == "dm") {
console.log(`${message.author.tag} tried to use a command in DM!`);
return logsCommands.send(`${message.author.tag} tried to use a command in DM!`);
}
//Users blacklist
if (message.author.id == "") {
console.log(`[BlackList] ${message.author.tag} tried to use a command!`);
return logsCommands.send(`[BlackList] ${message.author.tag} tried to use a command!`);
}
//Channels blacklist
if (message.channel.id == "") return;
//Servers blacklist
if (message.guild.id == "") return;
var args = message.content.substring(settings.botPREFIX.length).split(" ");
// Bot's commands from here.
switch (args[0]) {
case "info":
console.log(`${message.author.tag} used the ${settings.botPREFIX}info command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}info command!`);
message.channel.send({embed: {
color: 3447003,
title: "Info:",
description: "This is the info about the bot",
fields: [{
name: "Created by:",
value: "This bot created by [Blue Malgeran](http://BlueMalgeran.com)"
},
{
name: "Made with:",
value: "This bot made with [Discord.JS](http://discord.js.org)"
},
{
name: "Contact me:",
value: "_**Blue Malgeran#3106**_"
},
{
name: "Social Media",
value: "[Twitter](https://twitter.com/BlueMalgeran) | [Steam](http://steamcommunity.com/id/BlueMalgeran/) | [GitHub](https://github.com/BlueMalgeran)"
},
{
name: "Invite the bot here",
value: "[:robot:](https://discordapp.com/oauth2/authorize?client_id=" + client.user.id + "&scope=bot&permissions=0)"
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "8ball":
console.log(`${message.author.tag} used the ${settings.botPREFIX}8ball command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}8ball command!`);
let question = message.content.split(' ').slice(1).join(' ');
if (!question) {
return message.reply('What question should I answer on?\n\**Usage:** `~8ball is Blue Malgeran is sexy af?`');
}
message.channel.send({embed: {
color: 3447003,
author: {
name: `8ball`,
icon_url: 'http://8ballsportsbar.com/wp-content/uploads/2016/02/2000px-8_ball_icon.svg_.png'
},
fields: [{
name: 'Info:',
value: `**My answer:** ${fortunes[~~(Math.random() * fortunes.length)]}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "weather":
console.log(`${message.author.tag} used the ${settings.botPREFIX}weather command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}weather command!`);
let apiKey = settings.weatherAPI;
const fetch = require('node-fetch');
let arg = message.content.split(' ').join(' ').slice(9);
if (!arg) {
return message.reply('I need a city to check :wink:');
}
fetch('http://api.openweathermap.org/data/2.5/weather?q=' + arg + '&APPID=' + apiKey + '&units=metric')
.then(res => {
return res.json();
}).then(json => {
if (json.main === undefined) {
return message.reply(`**${arg}** Isnt inside my query, please check again`);
}
let rise = json.sys.sunrise;
let date = new Date(rise * 1000);
let timestr = date.toLocaleTimeString();
let set = json.sys.sunset;
let setdate = new Date(set * 1000);
let timesstr = setdate.toLocaleTimeString();
const embed = new Discord.RichEmbed()
.setColor(26368)
.setTitle(`This is the weather for :flag_${json.sys.country.toLowerCase()}: **${json.name}**`)
.addField('Information:', `**Temp:** ${json.main.temp}°C\n**Wind speed:** ${json.wind.speed}m/s\n**Humidity:** ${json.main.humidity}%\n**Sunrise:** ${timestr}\n**Sunset:** ${timesstr}`);
message.channel.send({embed})
.catch(console.error);
}).catch(err => {
if (err) {
message.channel.send('Something went wrong while checking the query!');
}
});
break;
case "invite":
console.log(`${message.author.tag} used the ${settings.botPREFIX}invite command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}invite command!`);
message.reply("Okay, you can invite me here: https://discordapp.com/oauth2/authorize?client_id=" + client.user.id + "&scope=bot&permissions=0");
break;
case "coinflip":
console.log(`${message.author.tag} used the ${settings.botPREFIX}coinflip command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}coinflip command!`);
let answers = [
'heads',
'tails'
];
message.channel.send({embed: {
color: 3447003,
title: "Coinflip:",
fields: [{
name: "Result",
value: `\`${answers[~~(Math.random() * answers.length)]}\``
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "userinfo":
console.log(`${message.author.tag} used the ${settings.botPREFIX}userinfo command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}userinfo command!`);
let user = message.mentions.users.first();
if (!user) {
return message.reply('You must mention someone!');
}
const mentioneduser = message.mentions.users.first();
const joineddiscord = (mentioneduser.createdAt.getDate() + 1) + '-' + (mentioneduser.createdAt.getMonth() + 1) + '-' + mentioneduser.createdAt.getFullYear() + ' | ' + mentioneduser.createdAt.getHours() + ':' + mentioneduser.createdAt.getMinutes() + ':' + mentioneduser.createdAt.getSeconds();
let game;
if (user.presence.game === null) {
game = 'Not currently Playing.';
} else {
game = user.presence.game.name;
}
let messag;
if (user.lastMessage === null) {
messag = 'He didnt sent a message.';
} else {
messag = user.lastMessage;
}
let status;
if (user.presence.status === 'online') {
status = ':green_heart:';
} else if (user.presence.status === 'dnd') {
status = ':heart:';
} else if (user.presence.status === 'idle') {
status = ':yellow_heart:';
} else if (user.presence.status === 'offline') {
status = ':black_heart:';
}
// Let afk;
// if (user.presence.data.afk === true) {
// afk = "✅"
// } else {
// afk = "❌"
// }
let stat;
if (user.presence.status === 'offline') {
stat = 0x000000;
} else if (user.presence.status === 'online') {
stat = 0x00AA4C;
} else if (user.presence.status === 'dnd') {
stat = 0x9C0000;
} else if (user.presence.status === 'idle') {
stat = 0xF7C035;
}
message.channel.send({embed: {
color: 3447003,
author: {
name: `Got some info about ${user.username}`,
icon_url: user.displayAvatarURL
},
fields: [{
name: '**UserInfo:**',
value: `**Username:** ${user.tag}\n**Joined Discord:** ${joineddiscord}\n**Last message:** ${messag}\n**Playing:** ${game}\n**Status:** ${status}\n**Bot?** ${user.bot}`
},
{
name: 'DiscordInfo:',
value: `**Discriminator:** ${user.discriminator}\n**ID:** ${user.id}\n**Username:** ${user.username}`
},
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "avatar":
console.log(`${message.author.tag} used the ${settings.botPREFIX}avatar command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}avatar command!`);
if(message.mentions.users.first()) { //Check if the message has a mention in it.
let user = message.mentions.users.first(); //Since message.mentions.users returns a collection; we must use the first() method to get the first in the collection.
let output = user.username + "#" + user.discriminator /*Username and Discriminator*/ +
"\nAvatar URL: " + user.avatarURL; /*The Avatar URL*/
message.channel.sendMessage(output); //We send the output in the current channel.
} else {
message.reply("Please mention someone :thinking:"); //Reply with a mention saying "Invalid user."
}
break;
case "serverinfo":
console.log(`${message.author.tag} used the ${settings.botPREFIX}serverinfo command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}serverinfo command!`);
let guildmessageServerInfo = message.guild;
let nameServerInfo = message.guild.name;
let createdAtServerInfo = moment(message.guild.createdAt).format('MMMM Do YYYY, h:mm:ss a');
let channelsServerInfo = message.guild.channels.size;
let ownerServerInfo = message.guild.owner.user.tag;
let memberCountServerInfo = message.guild.memberCount;
let largeServerInfo = message.guild.large;
let iconUrlServerInfo = message.guild.iconURL;
let regionServerInfo = message.guild.region;
let afkServerInfo = message.guild.channels.get(message.guild.afkChannelID) === undefined ? 'None' : message.guild.channels.get(guildmessageServerInfo.afkChannelID).name;
message.channel.send({embed: {
color: 3447003,
author: {
name: message.guild.name,
icon_url: message.guild.iconURL
},
title: "Server Information",
fields: [{
name: "Channels",
value: `**Channel Count:** ${channelsServerInfo}\n**AFK Channel:** ${afkServerInfo}`
},
{
name: "Members",
value: `**Member Count:** ${memberCountServerInfo}\n**Owner:** ${ownerServerInfo}\n**Owner ID:** ${message.guild.owner.id}`
},
{
name: "More",
value: `**Created at:** ${createdAtServerInfo}\n**Large Guild?:** ${largeServerInfo ? 'Yes' : 'No'}\n**Region:** ${regionServerInfo}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "botservers":
console.log(`${message.author.tag} used the ${settings.botPREFIX}botservers command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}botservers command!`);
let Table = require(`cli-table`);
let table = new Table({
head: [
`ID`,
`Name`,
`Users`,
`Bots`,
`Total`
], colWidths: [30, 50, 10, 10, 10]
});
client.guilds.map(g =>
table.push(
[g.id, g.name, g.members.filter(u => !u.user.bot).size, g.members.filter(u => u.user.bot).size, g.members.size]
));
require(`snekfetch`)
.post(`https://hastebin.com/documents`)
.set(`Content-Type`, `application/raw`)
.send(table.toString())
.then(r =>
message.channel.send(`Im inside these servers! http://hastebin.com/` + r.body.key));
break;
case "ping":
console.log(`${message.author.tag} used the ${settings.botPREFIX}ping command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}ping command!`);
var msTOcolor = (client.ping > 100) ? "15158332":"3066993"
message.channel.send({embed: {
color: msTOcolor,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
fields: [{
name: "Bot's ping:",
value: `\`${client.ping}ms\``
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "ban":
console.log(`${message.author.tag} used the ${settings.botPREFIX}ban command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}ban command!`);
const mmss = require('ms');
let reason = message.content.split(' ').slice(3).join(' ');
let time = message.content.split(' ')[2];
let guild = message.guild;
let modlog = message.guild.channels.find('name', 'mod-log');
let usermention = message.mentions.users.first();
if (!message.guild.member(message.author).hasPermission('BAN_MEMBERS')) {
return message.reply(':lock: **You** need `BAN_MEMBERS` Permissions to execute `ban`')
}
if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) {
return message.reply(':lock: **I** need `BAN_MEMBERS` Permissions to execute `ban`')
}
if (!modlog) {
return message.reply('I need a text channel named `mod-log` to print my ban/kick logs in, please create one')
}
if (message.mentions.users.size < 1) {
return message.reply('You need to mention someone to Ban them!')
}
if (message.author.id === usermention.id) {
return message.reply('You cant punish yourself :wink:')
}
if (!time) {
return message.reply(`How much time ? **Usage:**\`~ban [@mention] [1d] [example]\``)
}
if (!time.match(/[1-7][s,m,h,d,w]/g)) {
return message.reply('I need a valid time ! look at the Usage! right here: **Usage:**`~ban [@mention] [1m] [example]`')
}
if (!reason) {
return message.reply(`You must give me a reason for the ban **Usage:**\`~ban [@mention] [1d] [example]\``)
}
if (!message.guild.member(usermention).bannable) {
return message.reply('This member is above me in the `role chain` Can\'t ban them')
}
message.reply("This user has been banned from the server.");
usermention.send(`You've just got banned from ${guild.name} \n State reason: **${reason}** \n **Disclamer**: If the ban is not timed and Permanent you may not appeal the **BAN**!`)
message.guild.ban(usermention, 7);
setTimeout(() => {
message.guild.unban(usermention.id);
}, mmss(time));
modlog.send({embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
fields: [{
name: "Ban:",
value: `**Banned:** ${usermention.username}#${usermention.discriminator}\n**Moderator:** ${message.author.username} \n**Duration:** ${mmss(mmss(time), {long: true})} \n**Reason:** ${reason}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "kick":
console.log(`${message.author.tag} used the ${settings.botPREFIX}kick command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}kick command!`);
if (!message.guild.member(message.author).hasPermission('KICK_MEMBERS')) {
return message.reply(':lock: You dont have permissions for that')
}
if (!message.guild.member(client.user).hasPermission('KICK_MEMBERS')) {
return message.reply(':lock: **I** need `KICK_MEMBERS` Permissions to execute `kick`')
}
let usermentionkick = message.mentions.users.first();
let reasonkick = message.content.split(' ').slice(2).join(' ');
let guildkick = message.guild;
let modlogkick = message.guild.channels.find('name', 'mod-log');
let memberkick = message.guild.member;
// If(!message.member.roles.has(adminRole.id)) return message.reply(":lock: You dont have permissions for that");
if (!modlogkick) {
return message.reply('I need a text channel named `mod-log` to print my ban/kick logs in, please create one');
}
if (message.mentions.users.size < 1) {
return message.reply('You need to mention someone to Kick him!. **Usage:**`~kick [@mention] [example]`');
}
if (!reasonkick) {
return message.reply('You must give me a reason for kick **Usage:**`~kick [@mention] [example]`');
}
if (!message.guild.member(usermentionkick).kickable) {
return message.reply('This member is above me in the `role chain` Can\'t kick him');
}
message.guild.member(usermentionkick).kick();
modlogkick.send({embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
fields: [{
name: "Kick:",
value: `**Kicked:**${usermentionkick.username}#${usermentionkick.discriminator}\n**Moderator:** ${message.author.username} \n**Reason:** ${reasonkick}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "mute":
console.log(`${message.author.tag} used the ${settings.botPREFIX}mute command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}mute command!`);
if (!message.guild.member(message.author).hasPermission('MUTE_MEMBERS')) {
message.channel.send(':lock: **I** need `MANAGE_ROLES` Permissions to execute `mute`');
return;
}
if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES')) {
return message.reply(':lock: **I** need `MANAGE_ROLES` Permissions to execute `mute`')
}
const msmute = require('ms');
let reasonMute = message.content.split(' ').slice(3).join(' ');
let timeMute = message.content.split(' ')[2];
let guildMute = message.guild;
// Let adminRoleMute = guild.roles.find("name", "TOA");
let memberMute = message.guild.member;
let modlogMute = message.guild.channels.find('name', 'mod-log');
let userMute = message.mentions.users.first();
let muteRoleMute = client.guilds.get(message.guild.id).roles.find('name', 'NotAMute');
if (!modlogMute) {
return message.reply('I need a text channel named `mod-log` to print my ban/kick logs in, please create one');
}
if (!muteRoleMute) {
return message.reply('`Please create a role called "NotAMute"`');
}
if (message.mentions.users.size < 1) {
return message.reply('You need to mention someone to Mute him!.');
}
if (message.author.id === userMute.id) {
return message.reply('You cant punish yourself :wink:');
}
if (!timeMute) {
return message.reply('specify the time for the mute!**Usage:**`~mute [@mention] [1m] [example]`');
}
if (!timeMute.match(/[1-60][s,m,h,d,w]/g)) {
return message.reply('I need a valid time ! look at the Usage! right here: **Usage:**`~mute [@mention] [1m] [example]`');
}
if (!reasonMute) {
return message.reply('You must give me a reason for Mute **Usage:**`~mute [@mention] [15m] [example]`');
}
if (reasonMute.time < 1) {
return message.reply('TIME?').then(message => message.delete(2000));
}
if (reasonMute.length < 1) {
return message.reply('You must give me a reason for Mute');
}
message.guild.member(userMute).addRole(muteRoleMute)
setTimeout(() => {
message.guild.member(userMute).removeRole(muteRoleMute)
}, msmute(timeMute));
message.guild.channels.filter(textchannel => textchannel.type === 'text').forEach(cnl => {
cnl.overwritePermissions(muteRoleMute, {
SEND_MESSAGES: false
});
});
message.reply("This user has been muted.");
modlogMute.send({embed: {
color: 16745560,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
fields: [{
name: 'Mute',
value: `**Muted:**${userMute.username}#${userMute.discriminator}\n**Moderator:** ${message.author.username}\n**Duration:** ${msmute(msmute(timeMute), {long: true})}\n**Reason:** ${reasonMute}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "unmute":
console.log(`${message.author.tag} used the ${settings.botPREFIX}unmute command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}unmute command!`);
let guildUnmute = message.guild;
let argsUnmute = message.content.split(' ').slice(1);
let argresultUnmute = args.join(' ');
let reasonUnmute = args;
if (!message.guild.member(message.author).hasPermission('MUTE_MEMBERS')) {
return message.reply(':lock: **You** need `MUTE_MEMBERS` Permissions to execute `unmute`')
}
if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES')) {
return message.reply(':lock: **I** need `MANAGE_ROLES` Permissions to execute `unmute`')
}
let userUnmute = message.mentions.users.first();
let muteRoleUnmute = client.guilds.get(message.guild.id).roles.find('name', 'NotAMute');
if (message.mentions.users.size < 1) {
return message.reply('You need to mention someone to unmute him!.');
}
message.guild.member(userUnmute).removeRole(muteRoleUnmute).then(() => {
message.channel.send(`You've succesfully unmuted ${userUnmute}`);
});
break;
case "quote":
console.log(`${message.author.tag} used the ${settings.botPREFIX}quote command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}quote command!`);
const fetchquote = require('snekfetch');
fetchquote.get('http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en').then(quote => {
if (quote.body.quoteText === undefined) {
return message.reply('Something is messing up the API try again please!');
}
message.channel.send({embed: {
color: 3447003,
author: {
name: 'A smart guy said once:',
icon_url: 'http://pngimages.net/sites/default/files/right-double-quotation-mark-png-image-80280.png'
},
fields: [{
name: "Quote with source",
value: `"${quote.body.quoteText}"\n**Author:** ${quote.body.quoteAuthor}\n**Source:** ${quote.body.quoteLink}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
})
});
break;
case "notice":
console.log(`${message.author.tag} used the ${settings.botPREFIX}notice command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}notice command!`);
var hugs = [
"`\(^o^)/`",
"`d=(´▽`)=b`",
"`⊂((・▽・))⊃`",
"`⊂( ◜◒◝ )⊃`",
"`⊂(♡⌂♡)⊃`",
"`⊂(◉‿◉)つ`"
];
message.reply(`${hugs[~~(Math.random() * hugs.length)]}`);
break;
case "softban":
console.log(`${message.author.tag} used the ${settings.botPREFIX}softban command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}softban command!`);
let reasonSoftban = message.content.split(' ').slice(7).join(' ');
let timeSoftban = message.content.split(' ')[2];
let guildSoftban = message.guild;
let modlogSoftban = message.guild.channels.find('name', 'mod-log');
let userSoftban = message.mentions.users.first();
if (!message.guild.member(message.author).hasPermission('BAN_MEMBERS')) {
return message.reply(':lock: You need to have `BAN_MEMBERS` Permission to execute `SoftBan`');
}
if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) {
return message.reply(':lock: I need to have `BAN_MEMBERS` Permission to execute `SoftBan`');
}
if (!modlogSoftban) {
return message.reply('I need a text channel named `mod-log` to print my ban/kick logs in, please create one');
}
if (message.author.id === userSoftban.id) {
return message.reply('You cant punish yourself :wink:');
}
if (message.mentions.users.size < 1) {
return message.reply('You need to mention someone to SoftBan him!');
}
if (!reasonSoftban) {
return message.reply(`You must give me a reason for the ban **Usage:**\`~softban [@mention] [example]\``);
}
userSoftban.send(`You've just got softbanned from ${guildSoftban.name} \n State reason: **${reasonSoftban}** \n **Disclamer**: In a softban you can come back straight away, we just got your messages deleted`);
message.guild.ban(userSoftban, 2);
setTimeout(() => {
message.guild.unban(userSoftban.id);
}, 0);
modlogSoftban.send({embed: {
color: 0x18FE26,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
fields: [{
name: "Softban:",
value: `**Softbanned:** ${userSoftban.username}#${userSoftban.discriminator}\n**Moderator:** ${message.author.username}\n**Reason:** ${reasonSoftban}`
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
break;
case "todo":
console.log(`${message.author.tag} used the ${settings.botPREFIX}todo command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}todo command!`);
if (message.author.id == '153478211207036929') {
return message.channel.send(`**Unban command.**\n
**Bot's owner commands.**\n
**Some fun commands.**\n
~~Mute command~~\n
~~Unmute command~~\n
~~Server info~~\n
~~Softban command\n~~
**~~watch porn man~~**`);
} else {
message.react('❌');
message.channel.send(`\`📛\` You don't have permissions to execute that command.`);
}
break;
case "botname":
console.log(`${message.author.tag} used the ${settings.botPREFIX}botname command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}botname command!`);
const botusername = message.content.split(' ').slice(1).join(' ');
if (message.author.id == settings.ownerID) {
client.user.setUsername(botusername);
message.reply('Done. :ok_hand:');
} else {
message.react('❌');
message.channel.send(`\`📛\` You don't have permissions to execute that command.`);
}
break;
case "botavatar":
console.log(`${message.author.tag} used the ${settings.botPREFIX}botavatar command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}botavatar command!`);
const botavatar = message.content.split(' ').slice(1).join(' ');
var request = require("request").defaults({ "encoding" : null });
if (message.author.id == settings.ownerID) {
request(botavatar, function (err, res, body) {
if (!err && res.statusCode === 200) {
var data = "data:" + res.headers["content-type"] + ";base64," + new Buffer(body).toString("base64");
client.user.setAvatar(botavatar).catch((error) => { message.channel.send('Beep boop, something went wrong. Check the console to see the error.'); console.log('Error on setavatar command:', error); });
message.channel.send('Done. :ok_hand:');
}
});
} else {
message.react('❌');
message.channel.send(`\`📛\` You don't have permissions to execute that command.`);
}
break;
case "botnick":
console.log(`${message.author.tag} used the ${settings.botPREFIX}botnick command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}botnick command!`);
const botnickname = message.content.split(' ').slice(1).join(' ');
if (message.author.id == settings.ownerID){
message.guild.members.get(client.user.id).setNickname(botnickname);
message.channel.send('Done. :ok_hand:');
} else {
message.react('❌');
message.channel.send(`\`📛\` You don't have permissions to execute that command.`);
}
break;
case "eval":
console.log(`${message.author.tag} used the ${settings.botPREFIX}eval command!`);
const clean = text => {
if (typeof(text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
const evalargs = message.content.split(" ").slice(1);
if (message.author.id == settings.ownerID || message.author.id == '153478211207036929') {
try {
const code = evalargs.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), {code:"xl"});
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
} else {
message.react('❌');
message.channel.send(`\`📛\` You don't have permissions to execute that command.`);
};
break;
case "issue":
console.log(`${message.author.tag} used the ${settings.botPREFIX}issue command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}issue command!`);
message.reply('If the bot got some bugs you can report them here! :heart: https://github.com/BlueMalgeran/NotABot/issues');
break;
case "request":
console.log(`${message.author.tag} used the ${settings.botPREFIX}request command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}request command!`);
message.reply('If you want to request more cool features to the bot, you can request them here! :heart: https://github.com/BlueMalgeran/NotABot/pulls');
break;
case "shutdown":
console.log(`${message.author.tag} used the ${settings.botPREFIX}shutdown command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}shutdown command!`);
if (message.author.id == settings.ownerID || message.author.id == "153478211207036929") {
const filterYes = m => m.content.startsWith('yes');
message.reply('Shutting down... :skull:')
.then(m => {
process.exit()
});
} else {
message.react('❌');
message.channel.send(`\`📛\` You don't have permissions to execute that command.`);
}
break;
case "roll":
console.log(`${message.author.tag} used the ${settings.botPREFIX}roll command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}roll command!`);
let rollnumber = message.content.split(' ').slice(1).join(' ');
if (!rollnumber) {
return message.reply(`:game_die: Just rolled a number: **${Math.floor(Math.random() * 100) + 1}**`);
}
message.reply(`:game_die: Just rolled a number: **${Math.floor(Math.random() * rollnumber) + 1}**`);
break;
case "dick":
console.log(`${message.author.tag} used the ${settings.botPREFIX}dick command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}dick command!`);
// pretty shitty command
let dicksize = ["8=D", "8==D", "8===D", "8====D", "8=====D", "8======D", "8=======D", "8========D", "8=========D", "8==========D", "404 not found"];
let dickuser = message.mentions.users.first();
if (!dickuser) {
return message.channel.send('You must mention someone!\n(This is 100% accurate!)');
}
if (dickuser.id == "153478211207036929") {
return message.channel.send(`**${dickuser} Size: ** 8=============================D\nSized by **${message.author.tag}**`);
}
message.channel.send(`**${dickuser} Size: ** ${dicksize[~~Math.floor(Math.random() * dicksize.length)]}\nSized by **${message.author.tag}**`);
break;
case "dog":
console.log(`${message.author.tag} used the ${settings.botPREFIX}dog command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}dog command!`);
const dogsuperagent = require('superagent');
let {body} = await dogsuperagent
.get(`https://random.dog/woof.json`);
let dogpicembed = new Discord.RichEmbed()
.setColor('#ff9900')
.setTitle('Dog Picture')
.setImage(body.url);
message.channel.send(dogpicembed);
break;
case "say":
console.log(`${message.author.tag} used the ${settings.botPREFIX}say command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}say command!`);
const botsay = message.content.split(' ').slice(1).join(' ');
if (!botsay) return message.channel.send('Please tell me what to say!');
message.delete();
message.channel.send(botsay);
break;
case "translate":
console.log(`${message.author.tag} used the ${settings.botPREFIX}translate command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}translate command!`);
const translate = require('google-translate-api');
let toTrans = message.content.split(' ').slice(1);
let language;
language = toTrans[toTrans.length - 2] === 'to' ? toTrans.slice(toTrans.length - 2, toTrans.length)[1].trim() : undefined;
if (!language) {
return message.reply(`Please supply valid agruments.\n**Example** \`${settings.botPREFIX}translate [text] to [language]\``);
}
let finalToTrans = toTrans.slice(toTrans.length - toTrans.length, toTrans.length - 2).join(' ');
translate(finalToTrans, {to: language}).then(res => {
message.channel.send({embed: {
color: 3447003,
author: {
name: 'NotABot\'s translator',
icon_url: client.user.avatarURL
},
fields: [{
name: "Translator",
value: `**From:** ${res.from.language.iso}\n\`\`\`${finalToTrans}\`\`\`\n**To: **${language}\n\`\`\`${res.text}\`\`\``
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "© NotABot"
}
}
});
}).catch(err => {
message.channel.send({
embed: {
description: '❌ We could not find the supplied language.',
color: 0xE8642B
}
});
});
break;
case "anime":
console.log(`${message.author.tag} used the ${settings.botPREFIX}anime command!`);
logsCommands.send(`${message.author.tag} used the ${settings.botPREFIX}anime command!`);
const animesf = require('snekfetch');
let res = await animesf.get('http://api.cutegirls.moe/json');
if (res.body.status !== 200) {
return message.channel.send('An error occurred while processing this command.');
}