-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.js
5175 lines (5058 loc) · 280 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
var user_data = {}
var osu_track = []
var stored_map_ID = []
var easter_egg = {}
var cooldown = {}
var custom_command = {}
var user_economy_data = {}
var server_data = {}
var osuApik = process.env.OSU_KEY
const Discord = require('discord.js');
const nodeosu = require('node-osu');
const request = require('request-promise-native');
const calc = require('ojsama')
const rxcalc = require('rx-akatsuki-pp')
const fs = require('fs')
const cheerio = require('cheerio')
const jimp = require('jimp')
const generate = require('node-chartist');
const sharp = require('sharp')
const text2png = require('text2png')
const bot = new Discord.Client();
var osuApi = new nodeosu.Api(osuApik, {
notFoundAsError: false,
completeScores: true
});
var trackApi = new nodeosu.Api(osuApik, {
notFoundAsError: false,
completeScores: false
});
var ee = JSON.parse(process.env.EASTER_EGG)
var ee_number = 0
var loading = 1
var bot_ver = 'v4.0-osu-beta4'
var refresh = 0
var bot_command_help = []
function osu_ranking_letters(letter) {
const lettericon = {
"SSH": '<:rankingXH:520932395080482858>',
"SS": '<:rankingX:520932410746077184>',
"XH": '<:rankingXH:520932395080482858>',
"X": '<:rankingX:520932410746077184>',
"SH": '<:rankingSH:520932441687588864>',
"S": '<:rankingS:520932426449682432>',
"A": '<:rankingA:520932311613571072>',
"B": '<:rankingB:520932334061748224>',
"C": '<:rankingC:520932353103626271>',
"D": '<:rankingD:520932369172004869>',
"F": '<:rankingF:557836461077168138>'
}
return lettericon[letter]
}
function osu_mods_enum(mod, type) {
const numbermods = {
17: 'PF',
19: 'SO',
21: 'FL',
22: 'NC',
23: 'HT',
24: 'RX',
25: 'DT',
26: 'SD',
27: 'HR',
28: 'HD',
29: 'TD',
30: 'EZ',
31: 'NF'
}
const textmods = {
NoFail : "NF",
Easy : "EZ",
TouchDevice: "TD",
Hidden : "HD",
HardRock : "HR",
SuddenDeath: "SD",
DoubleTime : "DT",
HalfTime : "HT",
Nightcore : "NC",
Flashlight : "FL",
SpunOut : "SO",
Perfect : "PF"
}
var shortenmod = '+';
var bitpresent = 0
if (type == 'text') {
for (var i = 0; i < mod.length; i++) {
if (shortenmod.includes('DT') == true && textmods[mod[i]] == 'NC') {
shortenmod = shortenmod.substring(0,shortenmod.length - 2)
}
if (shortenmod.includes('SD') == true && textmods[mod[i]] == 'PF') {
shortenmod = shortenmod.substring(0,shortenmod.length - 2)
}
if (textmods[mod[i]]) {
shortenmod += textmods[mod[i]];
bitpresent += nodeosu.Constants.Mods[mod[i]]
}
}
if (mod.length == 0 || shortenmod == '+'){
shortenmod += 'No Mod';
}
} else if (type == 'number') {
bitpresent = mod
var bit = mod.toString(2)
var fullbit = "0000000000000000000000000000000".substr(bit.length) + bit
for (var i = 31; i >= 0; i--) {
if (fullbit[i] == 1) {
shortenmod += numbermods[i+1]
}
}
if (mod == 0) {
shortenmod += 'No Mod'
}
}
return {shortenmod: shortenmod, bitpresent: Number(bitpresent)}
}
function time_played(time) {
var dateago = new Date(time).getTime()
var datenow = new Date().getTime()
var datenew = new Date(datenow - 28800000 - dateago)
var sec = datenew.getUTCSeconds()
var min = datenew.getUTCMinutes()
var hour = datenew.getUTCHours()
var day = (datenew.getUTCDate() - 1)
var month = datenew.getUTCMonth()
var year = (datenew.getUTCFullYear() - 1970)
var text = ''
var count = 0
if (year > 0 && count < 2) {
text += year > 1 ? `${year} Years ` : `${year} Year `
count += 1
}
if (month > 0 && count < 2) {
text += month > 1 ? `${month} Months ` : `${month} Month `
count += 1
}
if (day > 0 && count < 2) {
text += day > 1 ? `${day} Days ` : `${day} Day `
count += 1
}
if (hour > 0 && count < 2) {
text += hour > 1 ? `${hour} Hours ` : `${hour} Hour `
count += 1
}
if (min > 0 && count < 2) {
text += min > 1 ? `${min} Minutes ` : `${min} Minute `
count += 1
}
if (sec > 0 && count < 2) {
text += sec > 1 ? `${sec} Seconds ` : `${sec} Second `
count += 1
}
text += ' ago'
return text
}
function beatmap_detail(mods,timetotal,timedrain,bpm,cs,ar,od,hp) {
var arms = 0
var odms = 0
mods = mods.toLowerCase()
function EZ() {
cs = cs / 2
ar = ar / 2
od = od / 2
hp = hp / 2
}
function HT() {
bpm = bpm / 1.33
if (ar < 5) {
arms = 1600 + ((5 - ar) * 160)
}
if (ar == 5) {
arms = 1600
}
if (ar > 5) {
arms = 1600 - ((ar - 5) * 200)
}
if (arms < 1200) {
ar = (1200 + 750 - arms) / 150
}
if (arms == 1200) {
ar = 5
}
if (arms > 1200) {
ar = (1200 + 600 - arms) / 120
}
if (od < 5) {
odms = 66 - ((5 - od) * 8)
}
if (od == 5) {
odms = 66
}
if (od > 5) {
odms = 66 - ((od - 5) * 8)
}
od = (odms - 79.6) / -6
hp = hp / 1.5
timetotal *= 1.5
timedrain *= 1.5
}
function HR() {
cs = cs * 1.3
ar = ar * 1.4
od = od * 1.4
hp = hp * 1.4
if (ar > 10) {
ar = 10
}
if (od > 10) {
od = 10
}
if (hp > 10) {
hp = 10
}
}
function DT() {
bpm = bpm * 1.5
if (ar < 5) {
arms = 800 + ((5 - ar) * 80)
}
if (ar == 5) {
arms = 800
}
if (ar > 5) {
arms = 800 - ((ar - 5) * 100)
}
if (arms < 1200) {
ar = (1200 + 750 - arms) / 150
}
if (arms == 1200) {
ar = 5
}
if (arms > 1200) {
ar = (1200 + 600 - arms) / 120
}
if (od < 5) {
odms = 33 + ((5 - od) * 4)
}
if (od == 5) {
odms = 33
}
if (od > 5) {
odms = 33 - ((od - 5) * 4)
}
od = (odms - 79.6) / -6
hp = hp * 1.5
timetotal /= 1.5
timedrain /= 1.5
}
if (mods.includes("ez") == true) {
EZ()
}
if (mods.includes("hr") == true) {
HR()
}
if (mods.includes("ht") == true) {
HT()
}
if (mods.includes("dt") == true || mods.includes("nc") == true) {
DT()
}
if (ar < 0) {
ar = 0
}
if (od < 0) {
od = 0
}
if (hp < 0) {
hp = 0
}
if (cs > 10) {
cs = 10
}
if (ar > 11) {
ar = 11
}
if (od > 11) {
od = 11
}
if (hp > 11) {
hp = 11
}
return {bpm: bpm, cs: cs, ar: ar, od: od, hp: hp, timetotal: timetotal, timedrain: timedrain}
}
async function precalc(beatmapid) {
var parser = new calc.parser()
var map = await request.get(`https://osu.ppy.sh/osu/${beatmapid}`)
parser.feed(map)
return parser
}
function osu_pp_calculator(parser,mods,combo,count100,count50,countmiss,acc,mode) {
var stars = new calc.diff().calc({map: parser.map, mods: mods})
var bpm = 0
var bpmchanged = 0
for (var i = 0; i < stars.map.timing_points.length; i++) {
if (stars.map.timing_points[i].change == true) {
bpmchanged += 1
bpm += 60000 / Number(stars.map.timing_points[i].ms_per_beat)
}
}
bpm = Math.round(bpm / bpmchanged)
var object = Number(stars.objects.length)
var accuracy = 0
if (mode == 'fc') {
var count300 = object - count100 - count50
accuracy = Number((300 * count300 + 100 * count100 + 50 * count50) / (300 * (count300 + count100 + count50 + countmiss)) * 100).toFixed(2)
}
if (mode == 'acc') {
accuracy = acc
}
var score = {
stars: stars,
combo: combo,
nmiss: countmiss,
acc_percent: accuracy
}
var pp = ''
if (mode == 'fc' || mode == 'acc') {
pp = calc.ppv2(score)
} else if (mode == 'rx_fc') {
pp = rxcalc.ppv2(score)
}
return {star: stars,pp: pp,acc: accuracy, bpm: bpm, ar: stars.map.ar, od: stars.map.od, hp: stars.map.hp, cs: stars.map.cs}
}
// fullbit[fullbit.length - (Math.log2( Mod's bitpresent ) + 1)] == 1
async function other_modes_precalc(beatmapid, mode, mod) {
var bit = mod.toString(2)
var fullbit = "0000000000000000000000000000000".substr(bit.length) + bit
var bitpresent = 0
var map = ''
if (fullbit[fullbit.length - (Math.log2(64) + 1)] == 1) {
bitpresent += 64
}
if (fullbit[fullbit.length - (Math.log2(256) + 1)] == 1) {
bitpresent += 256
}
if (fullbit[fullbit.length - (Math.log2(16) + 1)] == 1) {
bitpresent += 16
}
if (fullbit[fullbit.length - (Math.log2(2) + 1)] == 1) {
bitpresent += 2
}
if (bitpresent > 0) {
map = await osuApi.apiCall('/get_beatmaps', {b: beatmapid, m: mode, a: 1, mods: bitpresent})
} else {
map = await osuApi.apiCall('/get_beatmaps', {b: beatmapid, m: mode, a: 1})
}
var ar = map[0].diff_approach
var fc = Number(map[0].count_normal) + Number(map[0].count_slider)
if (mode == 2) {
var textmod = osu_mods_enum(mod, "number")
ar = beatmap_detail(textmod.shortenmod, 0, 0, 0, 0, map[0].diff_approach, 0, 0).ar
fc = map[0].max_combo
}
return {
star: Number(map[0].difficultyrating),
cs: Number(map[0].diff_size),
ar: Number(ar),
od: Number(map[0].diff_overall),
hp: Number(map[0].diff_drain),
circle: Number(map[0].count_normal),
slider: Number(map[0].count_slider),
fc: fc
}
}
function taiko_pp_calculator(star, od, fc, acc, miss, mod) {
// Maximum combo for converted taiko map is roughly estimated sadly :c
// Mod to binary
var bit = mod.toString(2)
var fullbit = "0000000000000000000000000000000".substr(bit.length) + bit
// Calc
if (fullbit[fullbit.length - (Math.log2(2) + 1)] == 1) {
od /= 2
}
if (fullbit[fullbit.length - (Math.log2(16) + 1)] == 1) {
od *= 1.4
}
od = Math.max(Math.min(od,10),0)
var max = 20
var min = 50
var result = min + (max - min) * od / 10
result = Math.floor(result) - 0.5
if (fullbit[fullbit.length - (Math.log2(256) + 1)] == 1) {
result /= 0.75
}
if (fullbit[fullbit.length - (Math.log2(64) + 1)] == 1 || fullbit[fullbit.length - (Math.log2(512) + 1)] == 1) {
result /= 1.5
}
od = Math.round(result * 100) / 100
var StrainValue = Math.pow(Math.max(1,star/0.0075) * 5 - 4,2)/100000
var LengthBonus = Math.min(1,fc/1500) * 0.1 + 1
StrainValue *= LengthBonus
StrainValue *= Math.pow(0.985,miss)
StrainValue *= Math.min(Math.pow(fc - miss,0.5) / Math.pow(fc,0.5),1)
StrainValue *= acc/100
var AccValue = Math.pow(150/od,1.1) * Math.pow(acc/100,15) * 22
AccValue *= Math.min(Math.pow(fc/1500,0.3),1.15)
var modMultiplier = 1.10
if (fullbit[fullbit.length - (Math.log2(8) + 1)] == 1) {
modMultiplier *= 1.10
StrainValue *= 1.025
}
if (fullbit[fullbit.length - (Math.log2(1) + 1)] == 1) {
modMultiplier *= 0.90
}
if (fullbit[fullbit.length - (Math.log2(1024) + 1)] == 1) {
StrainValue *= 1.05 * LengthBonus
}
return Math.pow(Math.pow(StrainValue,1.1) + Math.pow(AccValue,1.1),1.0/1.1) * modMultiplier;
}
function ctb_pp_calculator(star, ar, fc, combo, acc, miss, mod) {
// Mod to binary
var bit = mod.toString(2)
var fullbit = "0000000000000000000000000000000".substr(bit.length) + bit
// Conversion from Star rating to pp
var final = Math.pow(((5*(star)/ 0.0049)-4),2)/100000;
// Length Bonus
lengthbonus = (0.95 + 0.4 * Math.min(1.0, fc / 3000.0) + (fc > 3000 ? Math.log10(fc / 3000.0) * 0.5 : 0.0));
final *= lengthbonus;
// Miss Penalty
final *= Math.pow(0.97, miss);
// Not FC combo penalty
final *= Math.pow(combo/fc,0.8);
// AR Bonus
if (ar>9) {
final*= 1+ 0.1 * (ar - 9.0);
}
if (ar<8) {
final*= 1+ 0.025 * (8.0 - ar);
}
// Acc Penalty
final *= Math.pow(acc/100, 5.5);
// Mod applied
if (fullbit[fullbit.length - (Math.log2(8) + 1)] == 1) {
return final* (1.05 + 0.075 * (10.0 - Math.min(10, ar)))
} else if (fullbit[fullbit.length - (Math.log2(1024) + 1)] == 1) {
return final * 1.35 * lengthbonus
} else if (fullbit[fullbit.length - (Math.log2(1024) + 1)] == 1 && fullbit[fullbit.length - (Math.log2(8) + 1)] == 1) {
return final* 1.35 * lengthbonus*(1.05 + 0.075 * (10.0 - Math.min(10, ar)))
} else {
return final
}
}
function mania_pp_calculator(star, od, score, objects, mod) {
// Mod to binary
var bit = mod.toString(2)
var fullbit = "0000000000000000000000000000000".substr(bit.length) + bit
// Calc
var nerfod = fullbit[fullbit.length - (Math.log2(2) + 1)] == 1 ? 0.5 : 1
var nerfpp = (fullbit[fullbit.length - (Math.log2(2) + 1)] == 1 ? 0.5 : 1) * (fullbit[fullbit.length - (Math.log2(1) + 1)] == 1 ? 0.9 : 1)
//StrainBase
var sb = Math.pow(5*Math.max(1,star/0.2)-4,2.2)/135*(1+0.1*Math.min(1,objects/1500));
//StrainMultiplier
var sm = (score<500000) ? score/500000*0.1 : ((score<600000) ? (score-500000)/100000*0.3 : ((score<700000) ? (score-600000)/100000*0.25+0.3 : ((score<800000) ? (score-700000)/100000*0.2+0.55 : ((score<900000) ? (score-800000)/100000*0.15+0.75 : (score-900000)/100000*0.1+0.9))));
//AccValue
var av = (score>=960000) ? od*nerfod*0.02*sb*Math.pow((score-960000)/40000,1.1) : 0
return (0.73*Math.pow(Math.pow(av,1.1)+Math.pow(sb*sm,1.1),1/1.1)*1.1*nerfpp);
}
bot.on("ready", (ready) => {
async function getFile() {
try {
// Get User data
var backupmessage = await bot.channels.get('487482583362568212').fetchMessages({limit: 1})
var backup = backupmessage.first().attachments
var fileurl = backup.first().url
var file = await request.get(fileurl)
user_data = JSON.parse(file)
// Get track data
var trackmessage = await bot.channels.get('497302830558871552').fetchMessages({limit: 1})
var trackbackup = trackmessage.first().attachments
var trackurl = trackbackup.first().url
var trackdata = await request.get(trackurl)
osu_track = JSON.parse(trackdata)
// Get easter egg data
var eemessage = await bot.channels.get('569168849992417315').fetchMessages({limit: 1})
var eebackup = eemessage.first().attachments
var eeurl = eebackup.first().url
var eedata = await request.get(eeurl)
easter_egg = JSON.parse(eedata)
for (var i = 0 ; i < Object.keys(ee).length; i++) {
ee_number += '0'
}
// Get custom commands data
var ccmessage = await bot.channels.get('572585703989575683').fetchMessages({limit: 1})
var ccbackup = ccmessage.first().attachments
var ccurl = ccbackup.first().url
var ccdata = await request.get(ccurl)
custom_command = JSON.parse(ccdata)
// Get economy data
var ecomessage = await bot.channels.get('578105172237221889').fetchMessages({limit: 1})
var ecobackup = ecomessage.first().attachments
var ecourl = ecobackup.first().url
var ecodata = await request.get(ecourl)
user_economy_data = JSON.parse(ecodata)
// Get server data
var servermessage = await bot.channels.get('586397586802343936').fetchMessages({limit: 1})
var serverbackup = servermessage.first().attachments
var serverurl = serverbackup.first().url
var serverdata = await request.get(serverurl)
server_data = JSON.parse(serverdata)
loading = 0
} catch(error) {
loading = 0
}
}
getFile()
// Server count
function server_count() {
bot.channels.get("572093442042232842").setName(`Server Count: ${bot.guilds.size}`)
}
setInterval(server_count, 10000)
// osutrack
async function real_time_osu_track() {
console.log('osutrack: Checking')
for (var player = 0; player < osu_track.length ; player++) {
for (var i = 0; i < osu_track[player].trackonchannel.length; i++) {
if (bot.channels.get(osu_track[player].trackonchannel[i]) == undefined) {
if (osu_track[player].trackonchannel.length > 1) {
osu_track[player].trackonchannel.splice(i,1)
} else {
osu_track.splice(player,1)
}
}
}
// New
var name = osu_track[player].osuname
var top50 = osu_track[player].top50pp
var recent = await trackApi.getUserRecent({u: name, limit: 1})
if (recent.length !== 0) {
if (String(osu_track[player].recenttimeplay) !== String(recent[0].date)) {
console.log(osu_track[player].osuname + ' new recent')
osu_track[player].recenttimeplay = recent[0].date
var beatmapid = recent[0].beatmapId
var beatmap = await osuApi.getBeatmaps({b: beatmapid})
var beatmaptitle = beatmap[0].title
var beatmapidfixed = beatmap[0].beatmapSetId
var diff = beatmap[0].version
var count300 = Number(recent[0].counts['300'])
var count100 = Number(recent[0].counts['100'])
var count50 = Number(recent[0].counts['50'])
var countmiss = Number(recent[0].counts.miss)
var combo = recent[0].maxCombo
var fc = beatmap[0].maxCombo
var acc = Number((300 * count300 + 100 * count100 + 50 * count50) / (300 * (count300 + count100 + count50 + countmiss)) * 100)
var mod = recent[0].mods
var modandbit = osu_mods_enum(mod, 'text')
var shortenmod = modandbit.shortenmod
var bitpresent = modandbit.bitpresent
var parser = await precalc(beatmapid)
var recentcalc = osu_pp_calculator(parser,bitpresent,combo,count100,count50,countmiss,acc,'acc')
// if calc pp > top 50 then new osutop play
if(Number(recentcalc.pp.total) > Number(top50)) {
var best = await trackApi.getUserBest({u: name, limit: 50})
for (var i = 0; i < best.length; i++) {
if (String(best[i].date) === String(recent[0].date)) {
console.log(osu_track[player].osuname + ' new top play')
var user = await osuApi.getUser({u: name})
var country = String(user.country).toLowerCase()
var pp = Number(best[i].pp).toFixed(2)
var ppgain = (Number(user.pp.raw).toFixed(2) - Number(osu_track[player].lasttotalpp)).toFixed(2)
var scores = best[i].score
var perfect = best[i].perfect
var letter = best[i].rank
var rank = osu_ranking_letters(letter)
var fccalc = osu_pp_calculator(parser,bitpresent,fc,count100,count50,0,acc,'fc')
var star = Number(fccalc.star.total).toFixed(2)
var fcpp = Number(fccalc.pp.total).toFixed(2)
var fcacc = fccalc.acc
var fcguess = ``
if (letter == 'F') {
pp = 'No PP'
}
if (perfect == 0) {
fcguess = `| **${fcpp}pp for ${fcacc}%**`
}
var embed = new Discord.RichEmbed()
.setAuthor(`New #${i+1} for ${name} in osu!Standard:`, `http://s.ppy.sh/a/${user.id}.png?date=${refresh}`)
.setThumbnail(`https://b.ppy.sh/thumb/${beatmapidfixed}l.jpg`)
.setDescription(`
**[${beatmaptitle}](https://osu.ppy.sh/b/${beatmapid})** (${star}★) ${shortenmod} | **${pp}pp** (+${ppgain}pp)
${rank} *${diff}* | **Scores:** ${scores} | **Combo:** ${combo}/${fc}
**Accuracy:** ${acc.toFixed(2)}% [${count300}/${count100}/${count50}/${countmiss}] ${fcguess}
**#${osu_track[player].lastrank} → #${user.pp.rank} (:flag_${country}: : #${osu_track[player].lastcountryrank} → #${user.pp.countryRank})** | Total PP: **${user.pp.raw}**`)
for (var i = 0; i < osu_track[player].trackonchannel.length; i++) {
stored_map_ID.push({id:beatmapid,server: osu_track[player].trackonchannel[i], mode: "Standard"})
embed.setColor(bot.channels.get(osu_track[player].trackonchannel[i]).guild.me.displayColor)
bot.channels.get(osu_track[player].trackonchannel[i]).send({embed})
}
osu_track[player].lasttotalpp = user.pp.raw
osu_track[player].lastrank = user.pp.rank
osu_track[player].lastcountryrank = user.pp.countryRank
osu_track[player].top50pp = best[49].pp
break;
}
}
}
}
}
}
}
setInterval(real_time_osu_track, 60000)
});
bot.on("guildMemberAdd", (member) => {
async function welcome_message() {
if (member.guild.id == "450576647976910869") {
var imageholder = await jimp.read('./image/welcomebanner.png')
var avatar = await jimp.read(member.user.avatarURL)
var placeholder = await new jimp(563, 125)
avatar.resize(105,105)
placeholder.composite(avatar, 214, 10)
placeholder.composite(imageholder,0,0)
var text = await jimp.loadFont('./font/anjelika_36_white.fnt')
placeholder.print(text, 347, 10, member.user.username + ',')
placeholder.write('./welcome.png')
bot.channels.get("487479898903150612").send(`<@${member.id}>`, {files: ['./welcome.png']})
}
}
welcome_message()
})
bot.on("message", (message) => {
if (message.author.bot == false && loading == 0){
var msg = message.content.toLowerCase();
refresh = Math.round(Math.random()* 2147483648)
var command = msg.split(' ')[0]
var embedcolor = (message.guild == null ? "#7f7fff": message.guild.me.displayColor)
var bot_prefix = '!'
if (message.guild !== null && server_data[message.guild.id] !== undefined) {
bot_prefix = server_data[message.guild.id].prefix
}
function set_Command_cooldown(cdcommand,time) {
if (cooldown[message.author.id] == undefined) {
cooldown[message.author.id] = [cdcommand]
} else {
cooldown[message.author.id].push(cdcommand)
}
setTimeout(() => {
if (cooldown[message.author.id].length > 1) {
var pos = cooldown[message.author.id].indexOf(cdcommand)
cooldown[message.author.id].splice(pos,1)
} else {
delete cooldown[message.author.id]
}
}, time)
}
function find_discord_user(name) {
if (name !== '') {
if (name.includes('@') == true) {
var id = message.mentions.users.first().id
if (id == message.author.id) {
return message.author
} else {
return message.mentions.users.first()
}
} else if (message.guild !== null) {
var member = message.guild.members.array()
for (var i = 0; i < message.guild.memberCount; i++) {
if (member[i].nickname !== null) {
if (member[i].nickname.substring(0, name.length).toLowerCase() == name) {
return member[i].user
}
} else {
if (member[i].user.username.substring(0, name.length).toLowerCase() == name) {
return member[i].user
}
}
}
}
} else {
return null
}
}
// General related
if (command == bot_prefix + 'help') {
try {
function addhelp(helpcommand, fullcommand, description, option, example) {
var helptext = '```' + `{prefix}` + fullcommand + '```' + `\n${description}\n\n**---[Options]:**\n${option}\n\n**---[Example]:**\n` + `{prefix}`+ example
bot_command_help.push({command: helpcommand, helptext: helptext})
}
if (bot_command_help.length < 1) {
// General
addhelp('avatar', 'avatar (user)', "View a user's discord avatar", 'user: User you want to view (Has to be @user)', 'avatar @Tienei#0000')
addhelp('changelog', 'changelog', 'View update and fix for the bot', 'None', 'changelog')
addhelp('help', 'help (command)', 'Get a full command list or view a specific command help', 'command: Command help you wanted to see', 'help osu')
addhelp('ping', 'ping', 'Ping Bancho (probably making Bancho mad sometimes lol)\n100ms: Good\n200ms: OK\n300ms: Bad\n600ms: Pretty bad', 'None', 'ping')
addhelp('report', 'report (error)', 'Report an error or bug to the owner', 'error: Type any error or bug you found', 'report osu is broken')
addhelp('suggestion', 'suggestion (suggestion)', 'Suggesting an idea for the bot to the owner', 'error: Type any error or bug you found', 'report osu is broken')
addhelp('bot', 'bot', 'Get invitation of the bot', 'None', 'bot')
addhelp('checkbot', 'checkbot', 'Check the compatibility of the bot to the server permissions', 'None', 'checkbot')
addhelp('prefix','prefix (prefix)', 'Change the prefix for the entire server','prefix: The prefix you wanted','prefix >')
// Easter Egg
addhelp('ee', 'ee', 'View how many easter eggs you have', 'None', 'ee')
// Custom command
addhelp('customcmd', 'customcmd (action) (command)', 'Set a custom commands (Required Administration)', 'action: ``add`` ``list`` ``remove``\ncommand: Set a command you liked (do ``!help definedvar`` for more information)', 'customcmd add !hi Hello $0 and welcome to {server.name}')
// Fun
addhelp('hug', 'hug (user)', 'Hug someone', 'user: The name of the user (Discord)', 'hug Tienei')
addhelp('cuddle', 'cuddle (user)', 'Cuddle someone', 'user: The name of the user (Discord)', 'cuddle Tienei')
addhelp('slap', 'slap (user)', 'Slap someone', 'user: The name of the user (Discord)', 'slap Tienei')
addhelp('kiss', 'kiss (user)', 'Kiss someone (best not to kiss in public ;) )', 'user: The name of the user (Discord)', 'kiss Tienei')
addhelp('pat', 'pat (user)', 'Pat someone', 'user: The name of the user (Discord)', 'pat Tienei')
addhelp('poke', 'poke (user)', 'PatPoke someone', 'user: The name of the user (Discord)', 'poke Tienei')
addhelp('cry', 'cry', 'Crying.', 'None', 'cry')
addhelp('blush', 'blush', 'Blushing.', 'None', 'blush')
// Osu
addhelp('osu', 'osu (username) (options)', 'Get an osuStandard profile', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nDetailed `(-d)`: Get all the details of the player `(no param)`\nRank `(-rank)`: Get an osu!Standard profile by rank\nTop Skills `(-ts)`: Calculate player skill using bot formula', 'osu Tienei -d')
addhelp('taiko', 'taiko (username)', 'Get an osu!Taiko profile', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'taiko Tienei')
addhelp('ctb', 'ctb (username)', 'Get an osu!Catch the beat profile', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'ctb Tienei')
addhelp('mania', 'mania (username)', 'Get an osu!Mania profile', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'mania Tienei')
addhelp('osucard', 'osucard (username)', 'Generate an osu!card (Just for fun)','username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'osucard Tienei')
addhelp('taikocard', 'taikocard (username)', 'Generate a taiko!card (Just for fun)','username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'taikocard Tienei')
addhelp('ctbcard', 'ctbcard (username)', 'Generate a ctb!card (Just for fun)','username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'ctbcard Tienei')
addhelp('maniacard', 'maniacard (username)', 'Generate a mania!card (Just for fun)','username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'maniacard Tienei')
addhelp('osustatus', 'osustatus', 'Check osu current status (Information from @osustatus twitter)','None', '!osustatus')
addhelp('osutop', 'osutop (username) (options)', "View a player's osu!Standard top play", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nRecent Play `(-r)`: Get a top recent play from top 100 `(No param)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`\nGreater than `(-g)`: Get number of plays greater than certain amount of pp (Number)\nPage `(-page)`: Get top 100 in a form of pages `(No param)`\nSearch `(-search)`: Search for a specific play in top 100', 'osutop Tienei -m HDHR')
addhelp('taikotop', 'taikotop (username) (options)', "View a player's osu!Taiko top play", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nRecent Play `(-r)`: Get a top recent play from top 100 `(No param)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`\nGreater than `(-g)`: Get number of plays greater than certain amount of pp (Number)\nPage `(-page)`: Get top 100 in a form of pages `(No param)`\nSearch `(-search)`: Search for a specific play in top 100', 'taikotop Tienei -p 8')
addhelp('ctbtop', 'ctbtop (username) (options)', "View a player's osu!Catch the beat top play", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nRecent Play `(-r)`: Get a top recent play from top 100 `(No param)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`\nGreater than `(-g)`: Get number of plays greater than certain amount of pp (Number)\nPage `(-page)`: Get top 100 in a form of pages `(No param)`\nSearch `(-search)`: Search for a specific play in top 100', 'ctbtop Tienei -p 9')
addhelp('maniatop', 'maniatop (username) (options)', "View a player's osu!Mania top play", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nRecent Play `(-r)`: Get a top recent play from top 100 `(No param)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`\nGreater than `(-g)`: Get number of plays greater than certain amount of pp (Number)\nPage `(-page)`: Get top 100 in a form of pages `(No param)`\nSearch `(-search)`: Search for a specific play in top 100', 'maniatop Tienei -p 4')
addhelp('osutrack', 'osutrack (username)', "Track a player's osu!Standard top 50 (Required Administration)", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'osutrack Tienei')
addhelp('osutracklist', 'osutracklist', 'Get a list of player being tracked in the channel', 'None', 'osutracklist')
addhelp('untrack', 'untrack (username)', 'Untrack a player from the database (Required Administration)', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'untrack Tienei')
addhelp('recent', '[recent|r] (username) (options)', "Get player's most recent play", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nRecent Best `(-b)`: Get player most recent best from top 100 `(No param)`\nStandard `(-Standard)`\nTaiko `(-Taiko)`\nCTB `(-CTB)`\nMania `(-Mania)`', 'r Tienei -b')
addhelp('compare', '[compare|c] (username) ', 'Compare to the last play in the chat', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)\nPrevious Play `(-p)`: Get a previous play mentioned in the chat `(Number)`', 'c Tienei')
addhelp('osuset', 'osuset (username)', 'Link your profile to an osu! player', 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'osuset Tienei')
addhelp('osuavatar', 'osuavatar (username)', "Get player's osu! avatar", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'osuavatar Tienei')
addhelp('osusig', 'osusig (username)', "Generate a signature of a player's profile", 'username: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'osusig Tienei')
addhelp('map', '[map|m] (options)', 'Get details info of the map of the last play in the server', 'Mods: details info of the map with mods `(Shorten mods)`', 'm HDDT')
addhelp('topglobal', 'topglobal', 'Get a list of top 50 osu!Standard player', '', 'topglobal')
addhelp('topcountry', 'topcountry (country code)', 'Get a list of top 50 osu!Standard player of a country', 'country code: You can see a list right here: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes (Look at ISO 3166-1, Alpha-2 code)', 'topcountry US')
addhelp('calcpp', 'calcpp (map id) (mods) (acc) (combo) (miss)', "Calculate a play's pp", '**Needs all options to be calculated**', 'calcpp 1157868 nomod 100 1642 0')
addhelp('scores', 'scores (map link) (username)', "Get player's play on a specific map", 'Map link: Just get a beatmap link\nusername: osu!username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'scores https://osu.ppy.sh/b/1157868 Cookiezi')
addhelp('acc', 'acc (300) (100) (50) (miss)', 'Accuracy calculator', '**Needs all options to be calculated**', 'acc 918 23 2 0')
addhelp('rec', 'rec', 'Recommend you an osu beatmap', 'None', '!rec')
addhelp('leaderboard', 'leaderboard', 'Get a list of top player in the server\nNote: The player stats will only be updated if the you type **!osu** or a specific player **!osu (player name)** only if they in the server', 'None', 'leaderboard')
// Akatsuki
addhelp('akatsuki', 'akatsuki (username) (options)', 'Get an Akatuski Standard profile', 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)\nDetails `(-d)`: Get all the details of the player `(no param)`', 'akatsuki Tienei -d')
addhelp('akatr', 'akatr (username)', "Get player's most recent play", 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'akatr Tienei')
addhelp('akattop', 'akattop (username) (options)', "View a player's Akatsuki Standard top play", 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`', 'akattop Tienei -p 8')
addhelp('akatavatar', 'akatavatar (username)', "Get player's Akatsuki avatar", 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'akatavatar Tienei')
addhelp('akatsukiset', 'akatsukiset (username)', 'Link your profile to an Akatsuki player', 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'akatsukiset RelaxTiny')
addhelp('rxakatsuki', 'rxakatsuki (username) (options)', 'Get a Relax Akatuski Standard profile', 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)\nDetails `(-d)`: Get all the details of the player `(no param)`', 'akatsuki Tienei -d')
addhelp('rxakatr', 'rxakatr (username)', "Get player's most recent play", 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'rxakatr Tienei')
addhelp('rxakattop', 'rxakattop (username) (options)', "View a player's Relax Akatsuki Standard top play", 'username: Akatsuki username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`', 'rxakattop Tienei -p 8')
addhelp('calcrxpp', 'calrxcpp (map id) (mods) (acc) (combo) (miss)', "Calculate a play's relax pp (Akatsuki)", '**Needs all options to be calculated**', 'calcrxpp 1157868 nomod 100 1642 0')
// Ripple
addhelp('ripple', 'ripple (username) (options)', 'Get an Ripple Standard profile', 'username: Ripple username of the player (Space replaced with "_" or just use quotation mark ``"``)\nDetailed `(-d)`: Get all the detailed of the player `(no param)`', 'ripple Tienei -d')
addhelp('rippler', 'rippler (username)', "Get player's most recent play", 'username: Ripple username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'rippler Tienei')
addhelp('rippletop', 'rippletop (username) (options)', "View a player's Ripple Standard top play", 'username: Ripple username of the player (Space replaced with "_" or just use quotation mark ``"``)\nSpecific Play `(-p)`: Get a specific play from top 100 `(Number)`\nMods Play `(-m)`: Get a top mods play from top 100 `(Shorten mods)`', 'rippletop Tienei -p 8')
addhelp('rippleavatar', 'rippleavatar (username)', "Get player's Ripple avatar", 'username: Ripple username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'rippleavatar Tienei')
addhelp('rippleset', 'rippleset (username)', 'Link your profile to a Ripple player', 'username: Ripple username of the player (Space replaced with "_" or just use quotation mark ``"``)', 'rippleset RelaxTiny')
// Others
addhelp('definevar', 'Defined Variable for Custom command', 'user: ``selfname`` ``selfping`` ``selfcreatedtime`` ``selfpresence`` ``othercreatedtime`` ``otherpresence`` channel: ``selfname`` ``selflink`` ``members`` server: ``name`` ``members`` ``channels`` ``roles`` ``defaultchannel`` ``owner`` ``region`` ``createdtime``', '{require:admin}: Need Administrator to enable the command {$N}: Get text in message seperated by space (Not include command) {send:channelname "message"}: Send to a channel with a specific message', 'do ``!help customcmd``')
addhelp('osu -d calculation', 'Osu -d calculation', 'Star: Avg stars of the top 50 plays\nAim: Aim stars play * (CS ^ 0.1 / 4 ^ 0.1)\nSpeed: Speed stars play * (BPM ^ 0.3 / 180 ^ 0.3) * (AR ^ 0.1 / 6 ^ 0.1)\nAccuracy: (Plays accuracy ^ 2.5 / 100 ^ 2.5) * 1.08 * Map stars * (OD ^ 0.03 / 6 ^ 0.03) * (HP ^ 0.03 / 6 ^ 0.03)', 'None', 'None')
}
var generalhelp = '**--- [General]:**\n`avatar` `changelog` `help` `ping` `report` `suggestion` `ee` `customcmd` `bot` `prefix`'
var funhelp = '**--- [Fun]:**\n`hug` `cuddle` `slap` `kiss` `pat` `poke` `blush`'
var osuhelp = '**--- [osu!]:**\n`osu` `taiko` `ctb` `mania` `osutop` `taikotop` `ctbtop` `maniatop` `osutrack` `untrack` `map` `osuset` `osuavatar` `osusig` `recent` `compare` `calcpp` `scores` `acc` `rec` `topglobal` `topcountry` `leaderboard` `osucard`'
var akatsukihelp = '**--- [Akatsuki]:**\n`akatsuki` `akatr` `akatavatar` `akattop` `rxakatsuki` `rxakatr` `rxakattop`'
var ripplehelp = '**--- [Ripple]:**\n`ripple` `rippler` `rippleavatar` `rippletop`'
var otherhelp = '**--- [Other]:**\n`definevar` `osu -d calculation`'
var text = ''
if (msg.substring(6) == '') {
text = `${generalhelp}\n\n${funhelp}\n\n${osuhelp}\n\n${akatsukihelp}\n\n${ripplehelp}\n\n${otherhelp}\n\nFor more detailed infomation, type **${bot_prefix}help (command)**`
} else {
var getcmd = msg.substring(6)
if (bot_command_help.find(helpcmd => helpcmd.command).helptext == undefined) {
throw 'No command was found!'
}
if (getcmd == 'r') {
getcmd = 'recent'
}
if (getcmd == 'c') {
getcmd = 'compare'
}
if (getcmd == 'm') {
getcmd = 'map'
}
if (getcmd == 'bg') {
getcmd = 'background'
}
if (getcmd == 'lb') {
getcmd = 'leaderboard'
}
text = bot_command_help.find(helpcmd => helpcmd.command == getcmd).helptext
for (var i = 0; i < 2; i++) {
text = text.replace('{prefix}', bot_prefix)
}
}
const embed = new Discord.RichEmbed()
.setAuthor(`Commands for Tiny Bot ${bot_ver}`)
.setColor(embedcolor)
.setThumbnail(bot.user.avatarURL)
.setDescription(text)
message.channel.send({embed})
} catch (error) {
message.channel.send(String(error))
}
}
if (command == bot_prefix + 'credit') {
const embed = new Discord.RichEmbed()
.setAuthor(`Special thanks to:`)
.setColor(embedcolor)
.setThumbnail(bot.user.avatarURL)
.setDescription(`
**--- Special helper ❤:**
Great Fog (!m, partial !osud, !acc, total pp in !osud, v3, !osutop -a)
**--- Command idea from:**
Yeong Yuseong (!calcpp, !compare sorted by pp, !r Map completion, !osutop -p with ranges, !suggestion, !osu -d common mods, !c -p, !osutop -s), 1OneHuman (!mosutop, !rosutop, !scores), Shienei (!c Unranked pp calculation), jpg (Time ago), lokser (!osu -d length avg), Xpekade (Economy), Rimu (new !osu design), zibi (!topglobal, !topcountry), PotatoBoy123 (!lb)
**--- Tester:**
ReiSevia, Shienei, FinnHeppu, Hugger, rinku, Rosax, -Seoul`)
message.channel.send({embed})
}
if (command == bot_prefix + 'avatar') {
var user = find_discord_user(msg.substring(8))
var username = user.username
var image = user.avatarURL
const embed = new Discord.RichEmbed()
.setAuthor(`Avatar for ${username}`)
.setColor(embedcolor)
.setImage(image)
message.channel.send({embed})
}
if (command == bot_prefix + 'changelog') {
const embed = new Discord.RichEmbed()
.setAuthor(`Changelog for Tiny Bot ${bot_ver}`)
.setColor(embedcolor)
.setThumbnail(bot.user.avatarURL)
.setDescription(`
**Akatsuki and Ripple update v2:**
--- [October 23th]:
+ Redesign osucard
+ Added other modes card
--- [November 5th]:
+ Add other modes rank graph
+ Improve error handling
--- [November 28th]:
+ Update acc formula
--- [December 15th]:
+ Added osustatus
+ Fixed osu -rank not getting the correct player
+ Fixed "undefined" prefix
Note: This is an osu beta version, which mean it's still in development and new feature is coming later
`)
message.channel.send({embed})
}
if (command == bot_prefix + 'bot') {
const embed = new Discord.RichEmbed()
.setColor(embedcolor)
.setThumbnail(bot.user.avatarURL)
.setDescription(`**----- [Info]:**
Hello! I am Tiny Bot, a bot made by Tienei
こんにちは! 私はTieneiによって作られたボット、Tiny Botです <:chinoHappy:450684046129758208>
**-----**
To get started, type **"!help"** to get a list of command and then type **"!help (command)"** to get more detailed information
If you wanted to help me improve, type **"!report"** or **"!suggestion"**
**-----**
Link to invite me: [invite](https://discordapp.com/api/oauth2/authorize?client_id=470496878941962251&permissions=378944&scope=bot)
My senpai server: [server](https://discord.gg/H2mQMxd)`)
message.channel.send({embed})
}
if (command == bot_prefix + 'ping') {
try {
if (cooldown[message.author.id] !== undefined && cooldown[message.author.id].indexOf(command) !== -1) {
throw 'You need to wait 5 seconds before using this again!'
}
set_Command_cooldown(command, 5000)
async function Bancho() {
var timenow = Date.now()
var test = await osuApi.getUser({u: "peppy"})
var timelater = Date.now()
var ping = timelater - timenow
var visual = '['
for (var i = 0; i < 20; i++) {
var comp = (100 + Math.pow(100, 0.50 * Math.log(i)))
if (ping < comp) {
visual += '⎯'
} else {
visual += '▬'
}
}
visual += ']'
message.channel.send(`Bancho respond! **${ping}ms**
Good ${visual} Bad`)
}
Bancho()
} catch (error) {
message.channel.send(String(error))
}
}
if (command == bot_prefix + 'prefix' && message.guild !== null) {
try {
if (message.member.hasPermission("ADMINISTRATOR") == false) {
throw 'You need to have administrator to set prefix'
}
var new_prefix = msg.split(' ')[1]
set_Command_cooldown(command, 30000)
if (new_prefix == undefined) {
throw "You need to specify what prefix the bot should be"
}
if (new_prefix == '!') {
message.channel.send('Prefix has been set back to default: !')
delete server_data[message.guild.id]
} else {
if (server_data[message.guild.id] == undefined) {
server_data[message.guild.id] = {}
server_data[message.guild.id].prefix = new_prefix
} else {
server_data[message.guild.id].prefix = new_prefix
}
message.channel.send(`Prefix has been set to: ${new_prefix}`)
}
if (Object.keys(server_data).length < 1) {
server_data['a'] = 'a'
}
fs.writeFileSync('server.txt', JSON.stringify(server_data))
bot.channels.get('586397586802343936').send({files: [{
attachment: './server.txt',
name: 'server.txt'
}]})
} catch (error) {
message.channel.send(String(error))
}
}
if (command == bot_prefix + 'report' && message.guild !== null) {
try {
if (cooldown[message.author.id] !== undefined && cooldown[message.author.id].indexOf(command) !== -1) {
throw 'You need to wait 30 seconds before using this again!'
}
set_Command_cooldown(command, 30000)
var error = message.content.substring(8)
if (error == '') {
throw "Type an error"
}
var channelid = message.channel.id
var user = message.author.username
var pfp = message.author.avatarURL
const embed = new Discord.RichEmbed()
.setAuthor(`Username: ${user}`, pfp)
.setColor(embedcolor)
.setDescription(`
Channel ID: **${channelid}**
Problem: ${error}`)
bot.channels.get('564396177878155284').send({embed})
message.channel.send('Error has been reported')
} catch (error) {
message.channel.send(String(error))
}
}
if (command == bot_prefix + 'suggestion' && message.guild !== null) {
try {
if (cooldown[message.author.id] !== undefined && cooldown[message.author.id].indexOf(command) !== -1) {
throw 'You need to wait 30 seconds before using this again!'
}
set_Command_cooldown(command, 30000)
var suggestion = message.content.substring(12)
if (suggestion == '') {
throw 'Type a suggestion for the bot'
}
var channelid = message.channel.id
var user = message.author.username
var pfp = message.author.avatarURL
const embed = new Discord.RichEmbed()
.setAuthor(`Username: ${user}`, pfp)
.setColor(embedcolor)
.setDescription(`
Channel ID: **${channelid}**
Suggestion: ${suggestion}`)
bot.channels.get('564439362218229760').send({embed})