-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
1421 lines (1209 loc) · 58.6 KB
/
main.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 client = new Discord.Client({
partials: ["MESSAGE", "CHANNEL", "REACTION"]
});
// What is partials?
// Partials allow you to receive events that contains uncached instances.
// When you restart your bot, any cache will be lost, and you wouldn't be able to get the previous content (.fetch())
// We're activate this to prevent any mistakes.
let m = require('moment-duration-format'),
os = require('os'),
cpuStat = require('cpu-stat'),
ms = require('ms'),
moment = require('moment'),
fetch = require('node-fetch'),
parse_ms = require('parse-ms'),
dateformat = require('dateformat');
const NovelCovid = require("novelcovid");
const covid = require('novelcovid');
// you can choose which URL to use, this will not change the behaviour of the API
covid.settings({
baseUrl: 'https://corona.lmao.ninja'
})
client.mute = new Map();
const config = require('./config.json');
client.config = config;
const ytdl = require('ytdl-core');
const {
GiveawaysManager
} = require('discord-giveaways');
client.giveawaysManager = new GiveawaysManager(client, {
storage: "./giveaways.json",
updateCountdownEvery: 5000,
default: {
botsCanWin: false,
exemptPermissions: ["MANAGE_MESSAGES", "ADMINISTRATOR"],
embedColor: "#FF0000",
reaction: "🎉"
}
});
let memberlog = "788114505832857620";
client.on('guildMemberAdd', (member) => { // If a member joins
let channelID = '788114505832857620' // #Welcome channel ID
if (member.guild.id != '733403709416931449') return; // Server ID
let avatar = member.user.displayAvatarURL()
let embed = new Discord.MessageEmbed()
.setTitle('Welcome to the server!') // Sets Title...
.setDescription(`Welcome ${member.user} to the SolusMC Discord server!\n\nPlease read the rules channel and change your nickname to your in-game name to avoid confusion, keep in mind that rule breakers will be banned from the discord.`) // This @ts the player that joins
.setColor("00aaff") // Sets Embed Color
.setImage(avatar)
.setFooter(`Joined, ${member.guild}`) // Dynamic: True just means that it can support gifs
.setTimestamp() // Sets Timestamp located in footer // To put servers Avatar use member.guild.iconURL() Also supports Dynamic
client.channels.cache.get(channelID).send(embed) // Gets the ChannelID and then sends the message wherever the channel is located
/* member.roles.add("733403976258551838"); // Member role.*/
});
client.on("messageReactionAdd", async (reaction, user) => {
// If a message gains a reaction and it is uncached, fetch and cache the message.
// You should account for any errors while fetching, it could return API errors if the resource is missing.
if (reaction.message.partial) await reaction.message.fetch(); // Partial messages do not contain any content so skip them.
if (reaction.partial) await reaction.fetch();
if (user.bot) return; // If the user was a bot, return.
if (!reaction.message.guild) return; // If the user was reacting something but not in the guild/server, ignore them.
if (reaction.message.guild.id !== "733403709416931449") return; // Use this if your bot was only for one server/private server.
if (reaction.message.channel.id === "780676039596703754") { // This is a #self-roles channel.
if (reaction.emoji.name === "✅") {
reaction.users.remove(user);
await reaction.message.guild.members.cache.get(user.id).roles.add("733403976258551838")
return user.send("You have been verified!").catch(() => console.log("Failed to send DM."));
}
}
if (reaction.message.channel.id === "734914063154413620") { // This is a #self-roles channel.
if (reaction.emoji.name === "📢") {
await reaction.message.guild.members.cache.get(user.id).roles.add("758829094589956136")
return user.send("Announcements role was given!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🥇") {
await reaction.message.guild.members.cache.get(user.id).roles.add("758828199773208577");
return user.send("Events role was given!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🗳️") {
await reaction.message.guild.members.cache.get(user.id).roles.add("758828204549996564");
return user.send("Polls role was given!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🆕") {
await reaction.message.guild.members.cache.get(user.id).roles.add("758828201958703205");
return user.send("Updates role was given!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "📹") {
await reaction.message.guild.members.cache.get(user.id).roles.add("788840581639569418");
return user.send("Media role was given!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🎉") {
await reaction.message.guild.members.cache.get(user.id).roles.add("783524398757314581");
return user.send("Giveaway role was given!").catch(() => console.log("Failed to send DM."));
}
} else {
return; // If the channel was not a #self-roles, ignore them.
}
})
client.on("messageReactionRemove", async (reaction, user) => {
// We're gonna make a trigger, if the user remove the reaction, the bot will take the role back.
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.guild.id !== "733403709416931449") return;
if (reaction.message.channel.id === "734914063154413620") {
if (reaction.emoji.name === "📢") {
await reaction.message.guild.members.cache.get(user.id).roles.remove("758829094589956136")
return user.send("Announcements role was taken!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🥇") {
await reaction.message.guild.members.cache.get(user.id).roles.remove("758828199773208577")
return user.send("Events role was taken!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🗳️") {
await reaction.message.guild.members.cache.get(user.id).roles.remove("758828204549996564")
return user.send("Polls role was taken!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🆕") {
await reaction.message.guild.members.cache.get(user.id).roles.remove("758828201958703205")
return user.send("Updates role was taken!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "📹") {
await reaction.message.guild.members.cache.get(user.id).roles.remove("788840581639569418")
return user.send("Media role was taken!").catch(() => console.log("Failed to send DM."));
}
if (reaction.emoji.name === "🎉") {
await reaction.message.guild.members.cache.get(user.id).roles.remove("783524398757314581")
return user.send("Giveaway role was taken!").catch(() => console.log("Failed to send DM."));
}
} else {
return;
}
})
const queue = new Map();
client.on("ready", () => {
function randomStatus() {
let status = ["you!", "Kho!", "Lo-Fi", "code..."] // You can change it whatever you want.
let rstatus = Math.floor(Math.random() * status.length);
// client.user.setActivity(status[rstatus], {type: "WATCHING"});
// You can change the "WATCHING" into STREAMING, LISTENING, and PLAYING.
// Example: streaming
client.user.setActivity(status[rstatus], {
type: "LISTENING",
url: "https://open.spotify.com/playlist/0DhmM2Rre4leQVj2lhF6pd"
});
};
setInterval(randomStatus, 20000) // Time in ms. 30000ms = 30 seconds. Min: 20 seconds, to avoid ratelimit.
console.log('Online.')
})
client.once("reconnecting", () => {
console.log("Reconnecting!");
});
client.once("disconnect", () => {
console.log("Disconnect!");
});
const usersMap = new Map();
const LIMIT = 5;
const TIME = 5000;
const DIFF = 2500;
client.on('message', async message => {
if (message.author.bot) return; // Ignore if the user is a bot.
if (usersMap.has(message.author.id)) {
const userData = usersMap.get(message.author.id);
const {
lastMessage,
timer
} = userData;
const difference = message.createdTimestamp - lastMessage.createdTimestamp;
console.log(difference);
let msgCount = usersMap.get(message.author.id).msgCount;
if (difference > DIFF) {
console.log(timer);
clearTimeout(timer);
console.log("Cleared timeout!");
userData.msgCount = 1;
userData.lastMessage = message;
userData.timer = setTimeout(() => {
usersMap.delete(message.author.id);
console.log("Removed from reset.");
}, TIME);
usersMap.set(message.author.id, userData);
} else {
++msgCount;
if (parseInt(msgCount) === LIMIT) {
const role = message.guild.roles.cache.get("735688801698971649");
message.member.roles.add(role);
message.channel.send("You have been muted.");
msgCount = 0;
} else {
userData.msgCount = msgCount;
usersMap.set(message.author.id, userData);
}
}
} else {
let fn = setTimeout(() => {
usersMap.delete(message.author.id);
console.log("Removed from map.");
}, 5000);
usersMap.set(message.author.id, {
msgCount: 1,
lastMessage: message,
timer: fn
});
}
let prefix;
prefix = "?"; // If the server doesn't have any custom prefix, return default.
if (!message.content.startsWith(prefix)) return; // use this. so your bot will be only executed with prefix.
let args = message.content.slice(prefix.length).trim().split(/ +/g);
let msg = message.content.toLowerCase();
let cmd = args.shift().toLowerCase();
message.flags = [];
while (args[0] && args[0][0] === "-") {
message.flags.push(args.shift().slice(1)); // Message Flags: -default, -ban, -parameter
}
const serverQueue = queue.get(message.guild.id);
if (msg.startsWith(prefix + "play")) {
execute(message, serverQueue);
return;
} else if (message.content.startsWith(prefix + "skip")) {
skip(message, serverQueue);
return;
} else if (message.content.startsWith(prefix + "stop")) {
stop(message, serverQueue);
return;
}
if (msg.startsWith(prefix + "corona") || msg.startsWith(prefix + "coronavirus")) {
let corona = await covid.all()
let embed = new Discord.MessageEmbed()
.setTitle("Global Cases")
.setColor("#ff2050")
.setDescription("Sometimes case numbers may differ from small amount.")
.addField("Total Cases", corona.cases, true)
.addField("Total Deaths", corona.deaths, true)
.addField("Total Recovered", corona.recovered, true)
.addField("Today's Cases", corona.todayCases, true)
.addField("Today's Deaths", corona.todayDeaths, true)
.addField("Active Cases", corona.active, true);
return message.channel.send(embed)
}
if (msg.startsWith(prefix + "giveaway")) {
await message.delete()
if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send('You are not allowed to start giveaways');
let channel = message.mentions.channels.first();
if (!channel) return message.channel.send('Please provide a channel');
let giveawayDuration = args[1];
if (!giveawayDuration || isNaN(ms(giveawayDuration))) return message.channel.send('Pleae provide a valid duration');
let giveawayWinners = args[2];
if (isNaN(giveawayWinners) || (parseInt(giveawayWinners) <= 0)) return message.channel.send('Please provide a valid number of winners!');
let giveawayPrize = args.slice(3).join(" ");
if (!giveawayPrize) return message.channel.send('Ok then, I\'ll give away nothing');
client.giveawaysManager.start(channel, {
time: ms(giveawayDuration),
prize: giveawayPrize,
winnerCount: giveawayWinners,
hostedBy: client.config.hostedBy ? message.author : null,
messages: {
giveaway: (client.config.everyoneMention ? "<@&783524398757314581>\n\n" : ""),
giveawayEnded: (client.config.everyoneMention ? "<@&783524398757314581>\n\n" : "") + "🎉 GIVEAWAY ENDED 🎉",
timeRemaining: "Time remaining: **{duration}**",
inviteToParticipate: "React with 🎉 to enter",
winMessage: "Congrats {winners}, you won **{prize}**",
embedFooter: "Giveaway time!",
noWinner: "Couldn't determine a winner",
hostedBy: "Hosted by {user}",
winners: "winner(s)",
endedAt: "Ends at",
units: {
seconds: "seconds",
minutes: "minutes",
hours: "hours",
days: "days",
pluralS: false
}
}
})
client.channels.cache.get(773341699065774100).send("Giveaway starting...")
}
if (msg.startsWith(prefix + "reroll")) {
await message.delete()
if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send('You do not have permission to rerol giveaways');
if (!args[0]) return message.channel.send('No giveaway ID provided');
let giveaway = client.giveawaysManager.giveaways.find((g) => g.prize === args.join(" ")) || client.giveawaysManager.giveaways.find((g) => g.messageID === args[0]);
if (!giveaway) return message.channel.send('Couldn\'t find a giveaway with that ID/name');
client.giveawaysManager.reroll(giveaway.messageID)
.then(() => {
message.channel.send('Giveaway rerolled')
})
.catch((e) => {
if (e.startsWith(`Giveaway with ID ${giveaway.messageID} is not ended`)) {
message.channel.send('This giveaway hasn\'t ended yet')
} else {
console.error(e);
message.channel.send('An error occured')
}
})
}
if (msg.startsWith(prefix + "reaction-roles-embed")) {
await message.delete()
let channel = client.channels.cache.get("734914063154413620"); // We want to sent the embed, directly to this channel.
const embed = new Discord.MessageEmbed()
.setColor(0xaaff)
.setTitle("Self-Assigned Roles")
.setDescription(`📢 <@&758829094589956136> - By adding this role, you will receive notifications about important announcements.\n\n🥇 <@&758828199773208577> - By adding this role, you will receive notifications about the upcoming events.\n\n🗳️ <@&758828204549996564> - By adding this role, you will receive notifications about polls that can be server change!\n\n🆕 <@&758828201958703205> - By adding this role, you will receive notifications about any changes regarding the server.\n\n📹 <@&788840581639569418> - By adding this role, you will receive notifications for the content people with Media rank make.\n\n🎉 <@&783524398757314581> - By adding this role, you will receive notifications about any giveaways that are active.`) // We're gonna try an unicode emoji. Let's find it on emojipedia.com !
channel.send(embed).then(async msg => {
await msg.react("📢");
await msg.react("🥇");
await msg.react("🗳️");
await msg.react("🆕");
await msg.react("📹");
await msg.react("🎉");
// We're gonna using an await, to make the react are right in order.
})
}
if (msg.startsWith(prefix + "messageverify")) {
await message.delete()
const embed = {
"title": "Verification",
"description": "In order to get access to the rest of the discord server, please read the rules mentioned above and then react to this message!",
"color": "00aaff",
}
message.channel.send({
embed
});
}
if (msg.startsWith(prefix + 'bubble') || msg.startsWith(prefix + 'bubblewrap')) {
await message.delete()
message.channel.send("||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\n||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop|| ||Pop||\nVirtual bubble wrap!");
}
if (msg.startsWith(prefix + 'ht') || msg.startsWith(prefix + 'coinflip')) {
function doRandHT() {
var rand = ['HEADS!', 'TAILS!'];
return rand[Math.floor(Math.random() * rand.length)];
}
const embed = {
"title": `Here is the winner!`,
"description": doRandHT(),
"color": "00aa77",
};
message.channel.send({
embed
});
};
if (msg.startsWith(prefix + 'rd') || msg.startsWith(prefix + 'die') || msg.startsWith(prefix + 'rolldie') || msg.startsWith(prefix + 'rolladie')) {
function doRandRD() {
var rand = ['1!', '2!', '3!', '4!', '5!', '6!'];
return rand[Math.floor(Math.random() * rand.length)];
}
const embed = {
"title": `You rolled a`,
"description": doRandRD(),
"color": "00aa77",
};
message.channel.send({
embed
});
};
if (msg.startsWith(prefix + 'userinfo') || msg.startsWith(prefix + 'user')) {
let user = message.mentions.users.first() || message.author;
let userStatus;
if (user.presence.status === "dnd") userStatus = "Do Not Disturb";
if (user.presence.status === "idle") userStatus = "Idle";
if (user.presence.status === "offline") userStatus = "Offline";
if (user.presence.status === "online") userStatus = "Online";
function game() {
let game;
if (user.presence.activities.length >= 1) game = `${user.presence.activities[0].type} ${user.presence.activities[0].name}`;
else if (user.presence.activities.length < 1) game = "None"; // This will check if the user doesn't playing anything.
return game; // Return the result.
}
let x = Date.now() - user.createdAt; // Since the user created their account.
let y = Date.now() - message.guild.members.cache.get(user.id).joinedAt; // Since the user joined the server.
let created = Math.floor(x / 86400000); // 5 digits-zero.
let joined = Math.floor(y / 86400000);
const member = message.guild.member(user);
let nickname = member.nickname !== undefined && member.nickname !== null ? member.nickname : "None";
let createdate = moment.utc(user.createdAt).format("dddd, MMMM Do YYYY, HH:mm:ss"); // User Created Date
let joindate = moment.utc(member.joinedAt).format("dddd, MMMM Do YYYY, HH:mm:ss"); // User Joined the Server Date
let status = user.presence.status;
let avatar = user.avatarURL({
size: 2048
}); // Use 2048 for high quality avatar.
const embed = new Discord.MessageEmbed()
.setAuthor(user.tag, avatar)
.setThumbnail(avatar)
.setTimestamp()
.setColor(0x7289DA)
.addField("ID", user.id, true)
.addField("Nickname", nickname, true)
.addField("Created Account Date", `${createdate} \nsince ${created} day(s) ago`, true)
.addField("Joined Guild Date", `${joindate} \nsince ${joined} day(s) ago`, true)
.addField("Status", userStatus, true)
.addField("Game", game(), true)
message.channel.send(embed); // Let's see if it's working.
}
if (msg.startsWith(prefix + 'serverinfo')) {
await message.delete()
let icon = message.guild.iconURL({
size: 2048
}); // Server Avatar
let region = {
"brazil": "Brazil",
"eu-central": "Central Europe",
"singapore": "Singapore",
"london": "London",
"russia": "Russia",
"japan": "Japan",
"hongkong": "Hongkong",
"sydney": "Sydney",
"us-central": "U.S. Central",
"us-east": "U.S. East",
"us-south": "U.S. South",
"us-west": "U.S. West",
"eu-west": "Western Europe"
}
// Members
let member = message.guild.members;
let offline = member.cache.filter(m => m.user.presence.status === "offline").size,
online = member.cache.filter(m => m.user.presence.status === "online").size,
idle = member.cache.filter(m => m.user.presence.status === "idle").size,
dnd = member.cache.filter(m => m.user.presence.status === "dnd").size,
robot = member.cache.filter(m => m.user.bot).size,
total = message.guild.memberCount;
// Channels
let channels = message.guild.channels;
let text = channels.cache.filter(r => r.type === "text").size,
vc = channels.cache.filter(r => r.type === "voice").size,
category = channels.cache.filter(r => r.type === "category").size,
totalchan = channels.cache.size;
// Region
let location = region[message.guild.region];
// Date
let x = Date.now() - message.guild.createdAt;
let h = Math.floor(x / 86400000) // 86400000, 5 digits-zero.
let created = dateformat(message.guild.createdAt); // Install "dateformat" first.
const embed = new Discord.MessageEmbed()
.setColor(0x7289DA)
.setTimestamp(new Date())
.setThumbnail(icon)
.setAuthor(message.guild.name, icon)
.setDescription(`**ID:** ${message.guild.id}`)
.addField("Region", location)
.addField("Date Created", `${created} \nsince **${h}** day(s)`)
.addField("Owner", `**${message.guild.owner.user.tag}** \n\`${message.guild.owner.user.id}\``)
.addField(`Members [${total}]`, `Online: ${online} \nIdle: ${idle} \nDND: ${dnd} \nOffline: ${offline} \nBots: ${robot}`)
.addField(`Channels [${totalchan}]`, `Text: ${text} \nVoice: ${vc} \nCategory: ${category}`)
message.channel.send(embed); // Let's see if it's working!
}
if (msg.startsWith(prefix + 'ping')) {
try {
const m = await message.channel.send("Pinging..."); // Make sure the async is written, top of the client.on("message", ...)
const embed = new Discord.MessageEmbed()
.setColor("RANDOM") // Tired of choosing the embed colors? Just type "RANDOM" on it!
.addField("⌛ Latency", `**${m.createdTimestamp - message.createdTimestamp}ms**`)
.addField("💓 API", `**${Math.floor(client.ws.ping)}ms**`) // Use "client.ping" if your Discord.js is < 1.15.1 --- Use "client.ws.ping" if your Discord.js is > 12.0.0
return m.edit(`🏓 Pong!`, embed);
} catch (error) {
return message.channel.send(`Something went wrong: ${error.message}`);
// Restart the bot as usual.
}
} // easy way.
if (msg.startsWith(prefix + 'hello')) {
message.channel.send('hewwo'); // results.
}
if (msg.startsWith(prefix + 'stats')) {
await message.delete()
cpuStat.usagePercent(function(error, percent, seconds) {
if (error) {
return console.error(error)
}
const cores = os.cpus().length // Counting how many cores your hosting has.
const cpuModel = os.cpus()[0].model // Your hosting CPU model.
const guild = client.guilds.cache.size.toLocaleString() // Counting how many servers invite your bot. Tolocalestring, meaning separate 3 numbers with commas.
const user = client.users.cache.size.toLocaleString() // Counting how many members in the server that invite your bot.
const channel = client.channels.cache.size.toLocaleString() // Counting how many channels in the server that invite your bot.
const usage = formatBytes(process.memoryUsage().heapUsed) // Your memory usage.
const Node = process.version // Your node version.
const CPU = percent.toFixed(2) // Your CPU usage.
const embed = new Discord.MessageEmbed() // Stable or < below than 11.x.x use RichEmbed. More than 12.x.x or Master or https://github.com/discordjs/discord.js/ (github:discordjs/discord.js) use MessageEmbed.
// Actually they are exactly the same.
embed.addField('Bot Statistics:', `Server: ${guild} \nUser: ${user} \nChannel: ${channel} \nUsage: ${usage} \nNode: ${Node} \nCPU Usage: ${CPU}%`) // Use Grave accent or ``
// (its on your keyboard, besides on number 1.)
// Use \n to make a new line.
embed.addField('Physical Statistics:', `CPU: ${cores} - ${cpuModel}**`)
// Let's test it!
// Use ** turn the text into bold.
// Let's test again.
message.channel.send(embed)
})
}
if (msg.startsWith(prefix + "prune") || msg.startsWith(prefix + "purge")) { // You can make an aliases. Just like that.
if (!message.member.hasPermission("MANAGE_MESSAGES") || !message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You don't have a permissions to do this.");
if (isNaN(args[0])) return message.channel.send("Please input a valid number.") // isNaN = is Not a Number. (case sensitive, write it right)
if (args[0] < 100) {
await message.delete()
await message.channel.bulkDelete(args[0])
.then(messages => message.channel.send(`Deleted ${messages.size}/${args[0]} messages.`)).then(d => d.delete({
timeout: 10000
})) // How long this message will be deleted (in ms)
.catch(() => message.channel.send("Something went wrong, while deleting messages."))
}
if (args[0] < 2) return message.channel.send("Insert the number more than 1.")
await message.delete()
await message.channel.bulkDelete(args[0])
.then(messages => message.channel.send(`Deleted ${messages.size}/${args[0]} messages.`)).then(d => d.delete({
timeout: 10000
})) // How long this message will be deleted (in ms)
.catch(() => message.channel.send("Something went wrong, while deleting messages.")) // This error will be displayed when the bot doesn't have an access to do it.
}
if (msg.startsWith(prefix + "kick")) {
if (!message.member.hasPermission("KICK_MEMBERS") || !message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You don't have a permissions to do this.");
let user = message.mentions.users.first();
await message.delete()
let member = message.guild.member(user);
let reason = args.slice(1).join(" ");
if (!user) return message.channel.send("Please mention the user.");
if (user.id === message.author.id) return message.channel.send("You can't kick yourself.");
if (user.id === client.user.id) return message.channel.send("You can't kick me.");
if (!reason) reason = "No reason provided";
member.kick(reason).then(() => {
message.channel.send(`Successfully kicked **${user.tag}**`);
}).catch(err => {
message.reply("I was unable to kick the member.");
})
}
if (message.content.startsWith(prefix + "ban")) {
await message.delete()
if (!message.guild.member(message.author).hasPermission('BAN_MEMBERS')) {
return message.channel.send('You do not have the permission to ban users !');
}
if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) {
return message.channel.send('')
}
const PingCheckEmbed = new Discord.MessageEmbed()
.setTitle('**Incorrect Format**')
.setDescription(`**Format:**\n?ban [@user]`)
.setColor("RED")
.setFooter(`SolusMC`, message.author.displayAvatarURL({
dynamic: true
}))
.setTimestamp()
if (message.mentions.users.size === 0) {
return message.channel.send(PingCheckEmbed);
}
let banMember = message.guild.member(message.mentions.members.first().id);
if (!banMember) {
return message.channel.send('User not found!');
}
banMember.ban().then((member) => {
const BanEmbed = new Discord.MessageEmbed()
.setTitle('**Confirmed**')
.setDescription(`**Success**\nUser has succesfully been banned from the server.`)
.setColor("GREEN")
.setFooter(`SolusMC`, member.user.avatarURL({
dynamic: true
})) // Dynamic: True just means that it can support gifs
.setTimestamp() // Sets Timestamp located in footer // To put servers Avatar use member.guild.iconURL() Also supports Dynamic
message.channel.send(BanEmbed)
})
}
if (msg.startsWith(prefix + "avatar")) {
let user;
if (message.mentions.users.first()) {
user = message.mentions.users.first();
} else if (args[0]) {
user = message.guild.members.cache.get(args[0]).user;
} else {
user = message.author;
}
let avatar = user.displayAvatarURL({
size: 4096,
dynamic: true
});
// 4096 is the new biggest size of the avatar.
// Enabling the dynamic, when the user avatar was animated/GIF, it will result as a GIF format.
// If it's not animated, it will result as a normal image format.
const embed = new Discord.MessageEmbed()
.setTitle(`${user.tag} avatar`)
.setDescription(`[Avatar URL of **${user.tag}**](${avatar})`)
.setColor(0x1d1d1d)
.setImage(avatar)
return message.channel.send(embed);
}
if (msg.startsWith(prefix + "ytstats")) {
let name = args.join(" ");
if (!name) return message.channel.send("Unknown channel name.");
const channel = await fetch.get(`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${name}&key=${client.config.google}&maxResults=1&type=channel`)
.catch(() => message.channel.send("Unknown channel error."));
if (!channel.body.items[0]) return message.channel.send("No channel result. Try again.");
const data = await fetch.get(`https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails,statistics,brandingSettings&id=${channel.body.items[0].id.channelId}&key=${client.config.google}`)
.catch(() => message.channel.send("Unknown channel data error."));
const embed = new Discord.MessageEmbed()
.setColor(0x7289DA)
.setThumbnail(channel.body.items[0].snippet.thumbnails.high.url)
.setTimestamp(new Date())
.addField("Channel Name", channel.body.items[0].snippet.channelTitle, true)
.addField("Channel Description", channel.body.items[0].snippet.description, true)
.addField("Subscribers Count", parseInt(data.body.items[0].statistics.subscriberCount).toLocaleString(), true)
.addField("Total Views", parseInt(data.body.items[0].statistics.viewCount).toLocaleString(), true)
.addField("Total Video(s)", parseInt(data.body.items[0].statistics.videoCount).toLocaleString(), true)
.addField("Date Created", new Date(channel.body.items[0].snippet.publishedAt).toDateString(), true)
.addField("Link", `[${channel.body.items[0].snippet.channelTitle}](https://www.youtube.com/channel/${channel.body.items[0].id.channelId})`, true)
return message.channel.send(embed);
}
if (msg.startsWith(prefix + "binary")) {
if (!args[0]) return message.channel.send("Unknown parameter. Please choose the method first, either decode or encode it.");
let choice = ["encode", "decode"];
if (!choice.includes(args[0].toLowerCase())) return message.channel.send("Unknown parameter. Please choose the method first, either decode or encode it.");
let text = args.slice(1).join(" ");
// binary <encode | decode> <text>
// binary encode blob development
if (!text) return message.channel.send("Please input some text.");
// Do this because more than that, the binary code wouldn't be fit anymore.
if (text.length > 1024) return message.channel.send("Oww, that is way too much. The maximum character was 1,024.");
function encode(char) {
return char.split("").map(str => {
const converted = str.charCodeAt(0).toString(2);
return converted.padStart(8, "0");
}).join(" ")
};
function decode(char) {
return char.split(" ").map(str => String.fromCharCode(Number.parseInt(str, 2))).join("");
};
if (args[0].toLowerCase() === "encode") {
return message.channel.send(encode(text));
} else if (args[0].toLowerCase() === "decode") {
return message.channel.send(decode(text));
}
}
if (msg.startsWith(prefix + "spotify")) {
await message.delete()
let convert = require('parse-ms')
let user;
if (message.mentions.users.first()) {
user = message.mentions.users.first();
} else {
user = message.author;
}
let status;
if (user.presence.activities.length === 1) status = user.presence.activities[0];
else if (user.presence.activities.length > 1) status = user.presence.activities[1];
if (user.presence.activities.length === 0 || status.name !== "Spotify" && status.type !== "LISTENING") {
return message.channel.send("This user isn't listening to Spotify.");
}
if (status !== null && status.type === "LISTENING" && status.name === "Spotify" && status.assets !== null) {
let image = `https://i.scdn.co/image/${status.assets.largeImage.slice(8)}`,
url = `https:/open.spotify.com/track/${status.syncID}`,
name = status.details,
artist = status.state,
album = status.assets.largeText,
timeStart = status.timestamps.start,
timeEnd = status.timestamps.end,
timeConvert = convert(timeEnd - timeStart);
let minutes = timeConvert.minutes < 10 ? `0${timeConvert.minutes}` : timeConvert.minutes;
let seconds = timeConvert.seconds < 10 ? `0${timeConvert.seconds}` : timeConvert.seconds;
let time = `${minutes}:${seconds}`;
const embed = new Discord.MessageEmbed()
.setAuthor("Spotify Track Information", "https://image.flaticon.com/icons/svg/2111/2111624.svg")
.setColor(0x1ED768)
.setThumbnail(image)
.addField("Name:", name, true)
.addField("Album:", album, true)
.addField("Artist:", artist, true)
.addField("Duration:", time, false)
.addField("Listen now on Spotify!", `[\`${artist} - ${name}\`](${url})`, false)
return message.channel.send(embed)
}
}
if (msg.startsWith(prefix + "meme") || msg.startsWith(prefix + "memes")) {
await message.delete()
const got = require('got'),
{
MessageEmbed
} = require('discord.js');
got('https://www.reddit.com/r/meme/random/.json').then(response => {
let content = JSON.parse(response.body),
image = content[0].data.children[0].data.url,
embed = new MessageEmbed()
.setImage(image)
.setTimestamp()
.setFooter('from: r/meme')
message.channel.send(embed);
}).catch(console.log)
}
if (msg.startsWith(prefix + "programmingmeme") || msg.startsWith(prefix + "programmingmemes")) {
await message.delete()
const got = require('got'),
{
MessageEmbed
} = require('discord.js');
got('https://www.reddit.com/r/programmingmemes/random/.json').then(response => {
let content = JSON.parse(response.body),
image = content[0].data.children[0].data.url,
embed = new MessageEmbed()
.setImage(image)
.setTimestamp()
.setFooter('from: r/programmingmemes')
message.channel.send(embed);
}).catch(console.log)
}
if (msg.startsWith(prefix + "aww")) {
await message.delete()
const got = require('got'),
{
MessageEmbed
} = require('discord.js');
got('https://www.reddit.com/r/aww/random/.json').then(response => {
let content = JSON.parse(response.body),
image = content[0].data.children[0].data.url,
embed = new MessageEmbed()
.setImage(image)
.setTimestamp()
.setFooter('from: r/aww')
message.channel.send(embed);
}).catch(console.log)
}
if (msg.startsWith(prefix + "crappyoffbrand") || msg.startsWith(prefix + "offbrand")) {
await message.delete()
const got = require('got'),
{
MessageEmbed
} = require('discord.js');
got('https://www.reddit.com/r/crappyoffbrands/random/.json').then(response => {
let content = JSON.parse(response.body),
image = content[0].data.children[0].data.url,
embed = new MessageEmbed()
.setImage(image)
.setTimestamp()
.setFooter('from: r/crappyoffbrands')
message.channel.send(embed);
}).catch(console.log)
}
if (msg.startsWith(prefix + "dankmemes") || msg.startsWith(prefix + "dankmeme")) {
await message.delete()
const got = require('got'),
{
MessageEmbed
} = require('discord.js');
got('https://www.reddit.com/r/dankmemes/random/.json').then(response => {
let content = JSON.parse(response.body),
image = content[0].data.children[0].data.url,
embed = new MessageEmbed()
.setImage(image)
.setTimestamp()
.setFooter('from: r/dankmemes')
message.channel.send(embed);
}).catch(console.log)
}
if (msg.startsWith(prefix + "pat")) {
await message.delete()
const {
MessageAttachment
} = require('discord.js');
const {
body
} = fetch('https://nekos.life/api/v2/img/pat').then(res => res.json()).then(result => {
if (!result.url) return message.channel.send("Something went wrong.");
const attachment = new MessageAttachment(result.url);
message.channel.send(":)", attachment)
})
}
if (msg.startsWith(prefix + "meow")) {
await message.delete()
const {
MessageAttachment
} = require('discord.js');
const {
body
} = fetch('https://nekos.life/api/v2/img/meow').then(res => res.json()).then(result => {
if (!result.url) return message.channel.send("Something went wrong.");
const attachment = new MessageAttachment(result.url);
message.channel.send(attachment) // You can remove the :), it's optional.
})
}
if (msg.startsWith(prefix + "woof")) {
await message.delete()
const {
MessageAttachment
} = require('discord.js');
const {
body
} = fetch('https://nekos.life/api/v2/img/woof').then(res => res.json()).then(result => {
if (!result.url) return message.channel.send("Something went wrong.");
const attachment = new MessageAttachment(result.url);
message.channel.send(attachment) // You can remove the :), it's optional.
})
}
if (msg.startsWith(prefix + "mute")) {
await message.delete()
if (!message.member.hasPermission("MANAGE_MESSAGES") || !message.member.hasPermission("MUTE_MEMBERS") || !message.member.hasPermission("ADMINISTRATOR")) {
return message.channel.send("You don't have any permissions to do this: Manage Messages/Mute Members/Admin");
}
let user = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
if (!user) return message.channel.send("You need to mention the user.");
// Optional:
// if (user.id === client.user.id) return message.channel.send("You can't mute me.");
// if (user.id === message.author.id) return message.channel.send("You can't mute yourself.");
let role = message.guild.roles.cache.find(r => r.name === "Muted");
let bot = message.guild.members.cache.get(client.user.id).roles.highest;
if (!role) return message.channel.send("Couldn't find the mute role.");
if (role.position > bot.position) return message.channel.send("The role is higher than me.");
let time = args[1];
if (!time) {
if (user.roles.cache.has(role.id)) return message.channel.send("The user is still muted.");
await (user.roles.add(role.id).catch(err => message.channel.send(`Something went wrong: ${err}`)))
return message.channel.send(`${user.user.tag} is now muted.`);
} else {
if (user.roles.cache.has(role.id)) return message.channel.send("The user is still muted.");
await (user.roles.add(role.id).catch(err => message.channel.send(`Something went wrong: ${err}`)))
let timer = setTimeout(function() {
user.roles.remove(role.id).catch(err => message.channel.send(`Something went wrong: ${err}`));
message.channel.send(`${user.user.tag} is now unmuted.`);
}, ms(time))
client.mute.set(user.user.id, timer);
message.channel.send(`${user.user.tag} is now muted for **${ms(ms(time), {long: true})}**`);
}
}
if (msg.startsWith(prefix + "unmute")) {
await message.delete()
if (!message.member.hasPermission("MANAGE_MESSAGES") || !message.member.hasPermission("MUTE_MEMBERS") || !message.member.hasPermission("ADMINISTRATOR")) {
return message.channel.send("You don't have any permissions to do this: Manage Messages/Mute Members/Admin");
}
let user = message.guild.member(message.mentions.users.first()) || message.guild.members.cache.get(args[0]);
if (!user) return message.channel.send("You need to mention the user.");
let role = message.guild.roles.cache.find(r => r.name === "Muted");
if (!role) return message.channel.send("Couldn't find the mute role.");
if (!user.roles.cache.find(r => r.name === "Muted")) return message.channel.send("The user doesn't get muted.");
await user.roles.remove(role.id).catch(err => message.channel.send(`Something went wrong: ${err}`));
await clearTimeout(client.mute.get(user.user.id));
await client.mute.delete(user.user.id);
await message.channel.send(`${user.user.tag} is now unmuted.`);
}
if (msg.startsWith(prefix + "solus") || msg.startsWith(prefix + "info")) {
await message.delete()
const embed = {
"title": "SolusMC",
"description": "SolusMC is a **Cracked** Minecraft server founded by @Cicada3083 and it was released for the first time on **August 25, 2020**. Ever since, our server's player base is intermittently growing since it's first released, users around all over the world playing our amazing gamemodes and enjoying their time here with our beloved community. Can't wait to play? Join the community today!",
"color": "00aaff",
};
message.channel.send({
embed
});
}