-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
3465 lines (2852 loc) · 126 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 { //imports for discord.js
Client,
GatewayIntentBits,
Partials,
Collection,
Events,
MessageEmbed, // Change EmbedBuilder to MessageEmbed
permissions,
voiceschemas,
AttachmentBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
ModalBuilder,
TextInputBuilder,
PermissionsBitField,
TextInputStyle,
commands,
Options,
MessageActionRow,
MessageButton,
EmbedBuilder,
Embed,
ActivityType
} = require("discord.js");
const Discord = ('discord.js')
const { MessageAttachment } = require('discord.js')
const warnFilePath = './warns.json';
const { svg2png } = require('svg2png')
const { DisTube } = require("distube");
const config = require('./config.json');
//const { SpotifyPlugin } = require('@distube/spotify');
const translate = require('@iamtraction/google-translate');
const { SoundCloudPlugin } = require('@distube/soundcloud');
const { YtDlpPlugin } = require('@distube/yt-dlp');
const { handleLogs } = require('./Handlers/handleLogs');
const { handler } = require('./Handlers/handler');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');
const logs = require('discord-logs');
const Topgg = require('@top-gg/sdk');
const prefix = '?'; // Your bot's command prefix
const axios = require('axios');
const fetch = require('node-fetch');
const readdirSync = require('fs');
const banschema = require('./Schemas/ban.js');
const messageLogging = require('./Handlers/messageLogging');
const { ChannelType } = require('discord.js');
//use this if your bot on top.gg
const topggAPI = new Topgg.Api('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEwMjM4MTA3MTUyNTA4NjAxMDUiLCJib3QiOnRydWUsImlhdCI6MTY5NTQ2Njk0NX0.Gsc7utYgXzD_BZ04NafnBLKLprokL6pOL4bnIT2-xHw'); // If your bot added in top.gg line (1492) uncoment other function
const { loadEvents } = require("./Handlers/eventHandler");
const { loadCommands } = require("./Handlers/commandHandler");
const { loadModals } = require("./Handlers/modalHandler");
const { loadButtons } = require("./Handlers/buttonHandler");
const { LoadErrorHandler } = require("./Handlers/ErrorHandler");
const { loadComponents } = require('./Handlers/ComponentsHandler');
const { OpenAIApi, Configuration } = require("openai");
const { CaptchaGenerator } = require('captcha-canvas');
const modschema = require('./Schemas/modmailschema.js'); // Import the modschema model
const moduses = require ('./Schemas/modmailuses.js')
const client = new Client({
intents: [Object.keys(GatewayIntentBits)],
partials: [Object.keys(Partials)],
makeCache: Options.cacheWithLimits({
MessageManager: { maxSize: 0 },
PresenceManager: { mazSize: 0 },
}),
ctivities: [{
type: ActivityType.Custom,
name: "irrelevant", // name is exposed through the API but not shown in the client for ActivityType.Custom
state: "🎉 Custom Status"
}],
allowedMentions: { parse: ["users", "roles", "everyone"] },
});
client.setMaxListeners(50);
///reaction role system//
//reactionrole
const reactSchema = require("./Schemas/reactionrole");
client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.customId === "reactionrole") {
const guild = interaction.guild.id;
const message = interaction.message.id;
const reactchannel = interaction.channel.id;
const reactData = await reactSchema.findOne({
Guild: guild,
Message: message,
Channel: reactchannel
})
if (!reactData) {
return;
} else if (reactData) {
//Role ID
const ROLE_ID = reactData.Role;
//try add/remove role
try {
const targetMember = interaction.member;
const role = interaction.guild.roles.cache.get(ROLE_ID);
if (!role) {
interaction.reply({
content: 'Role not found.',
ephemeral: true
});
}
if (targetMember.roles.cache.has(ROLE_ID)) {
targetMember.roles.remove(role).catch(err => {console.log(err)});
interaction.reply({
content: `Removed the role ${role} from ${targetMember}.`,
ephemeral: true
});
} else {
await targetMember.roles.add(role).catch(err => {console.log(err)});;
interaction.reply({
content: `Added the role ${role} to ${targetMember}.`,
ephemeral: true
});
}
} catch (error) {
//catch the error
console.log(error);
interaction.reply('An error occurred while processing the command.');
}
}
}
})
//---- PİCK BUTTON ROLE SYSTEM ----//
client.on(Events.InteractionCreate, async (interaction) => {
const { customId, guild, channel, member, message } = interaction;
if (!interaction.isButton()) return;
const roleSchema = require("./Schemas/roleSchema");
const data = await roleSchema.findOne({
Guild: guild.id,
MessageID: message.id
});
if (customId === 'role-1') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID1);
if (role && member.roles.cache.has(data.RoleID1)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-2') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID2);
if (role && member.roles.cache.has(data.RoleID2)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-3') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID3);
if (role && member.roles.cache.has(data.RoleID3)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-4') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID4);
if (role && member.roles.cache.has(data.RoleID4)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-5') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID5);
if (role && member.roles.cache.has(data.RoleID5)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-6') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
member.roles.add(role);
const role = guild.roles.cache.get(data.RoleID6);
if (role && member.roles.cache.has(data.RoleID6)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-7') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID7);
if (role && member.roles.cache.has(data.RoleID7)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-8') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID8);
if (role && member.roles.cache.has(data.RoleID8)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-9') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID9);
if (role && member.roles.cache.has(data.RoleID9)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
if (customId === 'role-10') {
if (!data) return interaction.reply(`\`📛\` Error database!`);
const role = guild.roles.cache.get(data.RoleID10);
if (role && member.roles.cache.has(data.RoleID10)) {
member.roles.remove(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` ${role} role removed!`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else if (role) {
member.roles.add(role);
const embed1 = new EmbedBuilder()
.setColor("Green")
.setDescription(`\`✅\` You have chosen the ${role} role.`);
interaction.reply({ embeds: [embed1], ephemeral: true });
} else {
interaction.reply(`\`⚠️\` Role does not exist!`);
}
}
})
//animated logo//
//chat//
client.on('messageCreate', async (message) => {
if(message.guild) return;
await client.channels.cache.get('1192469305665785959').send(` **New DM Received** \n**By** - ${message.author} \n**Message** - ${message.content} `);
return;
});
////error jandler//
const errorHandling = require("discord.js-anticrash");
const configg = {
webhookUrl: 'https://discord.com/api/webhooks/1107776878615474208/g_2MV2f78JkZjktFr_7Kw66o1dIidJ3il3aPwlbkQUWW8ZAPBz93breP32yrI_AjEZzi',
embedColor: "#ff0000", // Optional
embedTitle: "Error", // Optional
embedAvatarUrl: "https://cdn.discordapp.com/avatars/1023810715250860105/a_22c18bd0084b1ec987598aa5a927647d.gif?size=2048", // Optional
webhookUsername: "Error", // Optional
};
errorHandling(client, config);
////join dm owner//
client.on('guildCreate', async (guild) => {
try {
const owner = await guild.members.fetch(guild.ownerId);
if (owner) {
const embed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Thank You for Adding Me!')
.setDescription(`<:utility12:1082695146560307281>Thanks for adding me to your server, ${owner.user.username}!`)
.addFields(
{ name: 'How to Use Me', value: '<:reply_end:1111372039463374880>You Can use me Via Slash command or prefix But Prefix Is Beta Now' }
// Add more fields as needed
);
owner.send({ embeds: [embed] });
console.log(`Sent thank-you message to ${owner.user.tag}`);
}
} catch (error) {
console.error(`Error sending thank-you message: ${error.message}`);
}
});
///rempve dm ////
client.on('guildDelete', async (guild) => {
try {
const owner = await guild.members.fetch(guild.ownerId);
if (owner) {
const embed = new EmbedBuilder()
.setColor('#ff0000')
.setTitle('Goodbye!')
.setDescription(`<:1984icondelete:1117884114259951636>I was removed from your server, ${owner.user.username}. KICKED ME MISTAKENLY?, Here you can [Add Me](https://top.gg/bot/1023810715250860105).`);
owner.send({ embeds: [embed] });
console.log(`Sent farewell message to ${owner.user.tag}`);
}
} catch (error) {
console.error(`Error sending farewell message: ${error.message}`);
}
});
//uncomnet this if you want to use bardai system
///end ////
client.on(Events.MessageCreate, async message => {
if (message.channel.type === ChannelType.DM) {
if (message.author.bot) return;
await message.channel.sendTyping();
let input = {
method: 'GET',
url: 'https://google-bard1.p.rapidapi.com/',
headers: {
text: message.content,
'x-RapidAPI-key': '454b8e539cmsh5fa0b025fa0d155p1102f3jsn570e16c1acc9',
'x-RapidAPI-Host': 'google-bard1.p.rapidapi.com',
}
};
try {
const output = await axios.request(input);
const response = output.data.response;
if (response.length > 2000) {
const chunks = response.match(/.{1,2000}/g);
for (let i = 0; i < chunks.length; i++) {
await message.author.send(chunks[i]).catch(err => {
message.author.send("I am having a hard time finding that request! Because I am an AI on Discord, I might have trouble with long requests.").catch(err => {});
});
}
} else {
await message.author.send(response).catch(err => {
message.author.send("I am having a hard time finding that request! Because I am an AI on Discord, I might have trouble with long requests.").catch(err => {});
});
}
} catch (e) {
console.log(e);
message.author.send("I am having a hard time finding that request! Because I am an AI on Discord, I might have trouble with long requests.").catch(err => {});
}
} else {
return;
}
});
///prefix system//
client.on('messageCreate', (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'devtest') {
const replyMessage = `The bot is working and online!\n My Prefix is: ${prefix}\n My Ping is: ${client.ws.ping}ms\n My Uptime is: ${client.uptime}ms\n I am in ${client.guilds.cache.size} servers!`;
message.reply(replyMessage);
}
});
client.on('messageCreate', (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'dev') {
const replyMessage = `The bot is owned by:\n- shykh69\n- typedrago\n\nDeveloped by:\n- Hotsuop\n- Titsou™!`;
message.reply(replyMessage);
}
});
// Random memme with ?meme
client.on('messageCreate', async (message) => {
if (message.content.toLowerCase() === '?meme') {
try {
const response = await fetch('https://www.reddit.com/r/memes/random/.json');
const data = await response.json();
const meme = data[0].data.children[0].data;
const memeTitle = meme.title;
const memeImage = meme.url;
message.channel.send({ content: memeTitle, files: [memeImage] });
} catch (error) {
console.error('Error fetching the meme:', error);
message.reply('There was an error while fetching the meme.');
}
}
});
// sunset image with ?sunset
client.on('ready', () => {
});
client.on('messageCreate', async (message) => {
if (message.content.toLowerCase() === '?sunset') {
try {
const response = await fetch(`https://api.unsplash.com/photos/random?query=sunset&orientation=landscape&client_id=dO6I6GGAh84-fQdTHpAUH2kzeLbd2rxALb-GUL9a7Ic`);
const data = await response.json();
const sunsetImage = data.urls.regular;
message.channel.send(sunsetImage);
} catch (error) {
console.error('Error fetching the sunset image:', error);
message.reply('There was an error while fetching the sunset image.');
}
}
});
// weather commannd
client.on('messageCreate', async (message) => {
if (message.content.startsWith('?weather')) {
const args = message.content.split(' ');
if (args.length < 2) {
message.reply('Please specify a location. Example: `?weather London`');
return;
}
args.shift(); // Remove the command ('?weather')
const location = args.join(' '); // Join the remaining args as the location
try {
const response = await axios.get(`https://api.openweathermap.org/data/2.5/weather?q=${encodeURIComponent(location)}&appid=cde77657814616656ba0de9fec623ed1&units=metric`);
const weatherData = response.data;
const weatherDescription = weatherData.weather[0].description;
const temperature = weatherData.main.temp;
const humidity = weatherData.main.humidity;
const windSpeed = weatherData.wind.speed;
const weatherInfo = `Weather in ${location}: ${weatherDescription}\nTemperature: ${temperature}°C\nHumidity: ${humidity}%\nWind Speed: ${windSpeed} m/s`;
message.channel.send(weatherInfo);
} catch (error) {
console.error('Error fetching weather:', error);
message.reply('There was an error while fetching the weather - Did you spell the location correctly?');
}
}
});
// server info (prefix)
client.on('messageCreate', async (message) => {
if (message.content.toLowerCase() === '?serverinfo') {
const guild = message.guild;
if (!guild) {
console.error('Guild not found.');
return;
}
const name = guild.name;
const memberCount = guild.memberCount;
const owner = guild.ownerId;
const serverAge = `<t:${Math.floor(guild.createdTimestamp / 1000)}:R>`;
const embed = {
color: 0x00ff00, // Green color in decimal format (you can change this)
title: 'Server Information',
fields: [
{ name: 'Server Name', value: `> ${name}` },
{ name: 'Server Member Count', value: `> ${memberCount}` },
{ name: 'Server Owner', value: `> ${owner}` },
{ name: 'Server Age', value: `> ${serverAge}` }
],
timestamp: new Date()
};
try {
await message.channel.send({ embeds: [embed] });
} catch (error) {
console.error('Error sending embed:', error);
message.reply('There was an error while sending the server information.');
}
}
});
// above is weather
// help command
// is here down
/* const commandsList = [
{
name: 'serverinfo',
description: 'Get information about the server',
usage: '?serverinfo',
category: 'Info',
},
{
name: 'meme',
description: 'Fetch a random meme',
usage: '?meme',
category: 'Fun',
},
{
name: 'sunset',
description: 'Get a random sunset image',
usage: '?sunset',
category: 'Image',
},
{
name: 'weather',
description: 'Get weather information for a location',
usage: '?weather <location>',
category: 'Info',
},
{
name: 'translate',
description: 'Translate text to a target language',
usage: '?translate <text> <target_language>',
category: 'Utilities',
},
{
name: 'slowmode',
description: 'Set channel slow mode',
usage: '?slowmode <seconds>',
category: 'Utilities',
},
{
name: 'joke',
description: 'Get a random joke',
usage: '?joke',
category: 'Fun',
},
{
name: 'ask',
description: 'Ask the AI a question',
usage: '?ask <your_question>',
category: 'Utilities',
},
// Add more commands as needed
];
const chunkArray = (array, chunkSize) => {
const chunks = [];
for (let i = 0; i < array.length; i += chunkSize) {
chunks.push(array.slice(i, i + chunkSize));
}
return chunks;
};
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
if (message.content.toLowerCase() === '?showhelp') {
// Display categories for help
const categories = [...new Set(commandsList.map((command) => command.category))];
const embed = new EmbedBuilder()
.setColor('#3498db')
.setTitle('Command Categories')
.setDescription('List of available categories:')
.addFields(categories.map((category) => {
return { name: category, value: `Use ?help ${category.toLowerCase()} for commands in this category` };
}));
message.channel.send({ embeds: [embed] });
} else {
// Handle commands based on categories
const commandCategory = message.content.toLowerCase().split(' ')[1];
const filteredCommands = commandsList.filter((command) =>
command.category.toLowerCase() === commandCategory.toLowerCase());
const pages = chunkArray(filteredCommands, 5);
let currentPage = 0;
const embed = new EmbedBuilder()
.setColor('#3498db')
.setTitle(`Commands in ${commandCategory}`)
.setDescription('List of available commands:')
.setFooter({ text: `Page ${currentPage + 1}/${pages.length}` });
embed.addFields(pages[currentPage].map((command) => {
return { name: command.name, value: `**Description:** ${command.description}\n**Usage:** ${command.usage}` };
}));
const helpMessage = await message.channel.send({ embeds: [embed] });
if (pages.length > 1) {
await helpMessage.react('⬅️');
await helpMessage.react('➡️');
}
const filter = (reaction, user) => ['⬅️', '➡️'].includes(reaction.emoji.name) && user.id === message.author.id;
const collector = helpMessage.createReactionCollector({ filter, time: 60000 });
collector.on('collect', async (reaction) => {
reaction.users.remove(message.author).catch(console.error);
if (reaction.emoji.name === '➡️' && currentPage < pages.length - 1) {
currentPage++;
} else if (reaction.emoji.name === '⬅️' && currentPage > 0) {
currentPage--;
}
embed.fields = [];
embed.setFooter({ text: `Page ${currentPage + 1}/${pages.length}` });
embed.addFields(pages[currentPage].map((command) => {
return { name: command.name, value: `**Description:** ${command.description}\n**Usage:** ${command.usage}` };
}));
await helpMessage.edit({ embeds: [embed] });
});
collector.on('end', () => {
helpMessage.reactions.removeAll().catch(console.error);
});
}
}); */
//translate modual
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.content.startsWith(`?help`)) {
// this is the code for the embeds that you will see
let embeds = [
new EmbedBuilder().setTitle(`📘 **Help Menu**`).setDescription(`Welcome to the help menu. Use the buttons below to navigate between pages.`).setFields({ name: 'Command', value: '?help and /help', inline: true }, { name: 'Description', value: 'Gives this help menu', inline: true }),
new EmbedBuilder().setTitle(`Info commands`).setDescription(`Info commands!`).setFields({ name: 'Command', value: '?Serverinfo\n?weather <location>\n?ping', inline: true }, { name: 'Description', value: 'Gives server info\nGives weather info for a location\n Gives the bots ping', inline: true }),
new EmbedBuilder().setTitle(`Image commands!`).setDescription(`Image commands!`).setFields({ name: 'Command', value: '?meme\n?sunset\n\n i will be adding more soon!', inline: true }, { name: 'Description', value: 'Gives a meme\nGives the sunset time of a location\n\n i will be adding more soon!', inline: true }),
new EmbedBuilder().setTitle(`Utility commands!`).setDescription(`Utility commands!`).setFields({ name: 'Command', value: '?avatar\n?servericon\n?serverinfo\n?userinfo', inline: true }, { name: 'Description', value: 'Gives the avatar of the member\nGives the server icon\nGives the server info\nGives the user info', inline: true }),
new EmbedBuilder().setTitle(`Ai commands!`).setDescription(`Ai commands!`).setFields({ name: 'Command', value: '?ask <text>', inline: true }, { name: 'Description', value: 'Chat with the ai!', inline: true }),
new EmbedBuilder().setTitle(`Admin commands`).setDescription(`Admin commands!`).setFields({ name: 'Command', value: '?kick\n?ban\n?mute \n?unmute\n?chatsave\n?addrole\n?removerole\n?slowmode', inline: true }, { name: 'Description', value: 'Kicks a member\nBans a member\nMutes a member\nUnmutes a member\nsaves the last 100 messages of the chat and sends it as an html file.\n adds a role\n removes a role\n Sets the slowmode of the channel', inline: true }),
new EmbedBuilder().setTitle(`Support and Invite`).setDescription(`If you need help, you can join the support server. You can also invite the bot to your server.`).setFields({ name: 'Support Server', value: 'https://discord.gg/DYhTZdpznE', inline: true }, { name: 'Invite', value: '[Click here to add the bot to your server!](https://discord.com/api/oauth2/authorize?client_id=1180863896773468351&permissions=8&scope=bot%20applications.commands)', inline: true }),
new EmbedBuilder().setTitle(`Credits for develpoping this bot`).setDescription(`Thanks to all who gave me ideas! Most namely <@!1178075092815716503>`).setFields({ name: 'Owners', value: '<@!903237169722834954>\n<@!930450658971234326>\n<@!804418829065125909>', inline: true },{ name: 'Devs', value: '<@!969655699154042940>\n<@!1175040737784643637>\n<@!487546381033013249>', inline: true },{name: 'Feature suggestions', value: 'Ps if you want to give me an idea/feature suggestion send me a dm! Or join our support server and say in chat!', inline: false },{ name: 'Support Server', value: 'https://discord.gg/DYhTZdpznE', inline: true }, { name: 'Invite', value: '[Click here to add the bot to your server!](https://discord.com/api/oauth2/authorize?client_id=845041532694199838&permissions=8&scope=bot%20applications.commands)', inline: true }),
];
await pagination(message, embeds);
}
});
/**
*
* @param {CommandInteraction} interaction
* @param {Array} embeds
* Below is the code for the buttons
*/
async function pagination(interaction, embeds) {
let allbuttons = new ActionRowBuilder().addComponents([
new ButtonBuilder().setStyle(2).setCustomId("0").setLabel("<<"),
new ButtonBuilder().setStyle(2).setCustomId("1").setLabel("<"),
new ButtonBuilder().setStyle(2).setCustomId("2").setLabel("x"),
new ButtonBuilder().setStyle(2).setCustomId("3").setLabel(">"),
new ButtonBuilder().setStyle(2).setCustomId("4").setLabel(">>"),
]);
// send message if embeds is 1
if (embeds.length === 1) {
if (interaction.deferred) {
return interaction.followUp({
title: "Your Embed Title",
description: "Your Embed Description",
embeds: [embeds[0]],
});
} else {
return interaction.reply({
title: "Your Embed Title",
description: "Your Embed Description",
embeds: [embeds[0]],
fetchReply: true,
});
}
}
embeds = embeds.map((embed, index) => {
return embed.setFooter({
text: `Page ${index + 1}/${embeds.length} - Expert help menu`,
iconURL: interaction.guild.iconURL({ dynamic: true }),
});
});
let sendMsg;
if (interaction.deferred) {
sendMsg = await interaction.followUp({
title: "Your Embed Title",
description: "Your Embed Description",
embeds: [embeds[0]],
components: [allbuttons],
});
} else {
sendMsg = await interaction.reply({
title: "Your Embed Title",
description: "Your Embed Description",
embeds: [embeds[0]],
components: [allbuttons],
});
}
let filter = (m) => m.member.id === interaction.member.id;
const collector = await sendMsg.createMessageComponentCollector({
filter: filter,
time: 30000,
});
let currentPage = 0;
collector.on("collect", async (b) => {
if (b.isButton()) {
await b.deferUpdate().catch((e) => null);
// page first
switch (b.customId) {
case "0":
{
if (currentPage != 0) {
currentPage = 0;
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
}
}
break;
case "1":
{
if (currentPage != 0) {
currentPage -= 1;
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
} else {
currentPage = embeds.length - 1;
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
}
}
break;
case "2":
{
allbuttons.components.forEach((btn) => btn.setDisabled(true));
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
}
break;
case "3":
{
if (currentPage < embeds.length - 1) {
currentPage++;
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
} else {
currentPage = 0;
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
}
}
break;
case "4":
{
currentPage = embeds.length - 1;
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
}
break;
default:
break;
}
}
});
collector.on("end", async () => {
allbuttons.components.forEach((btn) => btn.setDisabled(true));
await sendMsg
.edit({
embeds: [embeds[currentPage]],
components: [allbuttons],
})
.catch((e) => null);
});
}
// server icon
client.on('messageCreate', async (message) => {
if (!message.guild || message.author.bot) return;
const args = message.content.trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === '?servericon') {
const embed = new EmbedBuilder()
.setColor('#3498db')
.setTitle(`Icon of ${message.guild.name}`)
.setImage(message.guild.iconURL({ dynamic: true, size: 4096 }))
.setTimestamp();
message.channel.send({ embeds: [embed] });
}
});
//
/*client.on('messageCreate', async (message) => {
if (message.author.bot) return;
const args = message.content.toLowerCase().split(' ');
if (args[0] === '?translate') {
const text = args.slice(1, -1).join(' ');
const targetLanguage = args[args.length - 1];
if (!text || !targetLanguage) {
return message.reply('Please provide text and the target language for translation.');
}
try {
const translation = await translate(text, { to: targetLanguage });
const translatedText = translation.text ? translation.text : 'Unable to translate';
const embed = new EmbedBuilder()
.setTitle('Translation')
.setDescription(`**Original:** ${text}\n**Translated:** ${translatedText}`)
.setColor('#00FFFF')
.setFooter('Translated using Google Translate');
message.channel.send({ embeds: [embed] });
} catch (error) {
console.error('Error translating text:', error);
message.reply('An error occurred while translating the text.');
}
}
});*/
//Slow mode
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
const args = message.content.toLowerCase().split(' ');
if (args[0] === '?slowmode') {
if (!message.member.permissions.has('MANAGE_CHANNELS')) {