forked from NICK-FURY-6023/Expert-v3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
2072 lines (1649 loc) · 76 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,
} = require("discord.js");
const Discord = ('discord.js')
const { MessageAttachment } = require('discord.js')
const { svg2png } = require('svg-png-converter')
const { DisTube } = require("distube");
const prefix = '?'; // You can change the prefix of the bot this by changing this
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 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('Your_topp.gg_token'); // 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 contextMenu = require('fs').readdirSync('./context-menus').filter(file => file.endsWith('.js'));
const client = new Client({
intents: [Object.keys(GatewayIntentBits)],
partials: [Object.keys(Partials)],
makeCache: Options.cacheWithLimits({
MessageManager: { maxSize: 0 },
PresenceManager: { mazSize: 0 },
}),
allowedMentions: { parse: ["users", "roles", "everyone"] },
});
///levelingroles//
//shardingg//
////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': 'api of rapid ,//enter your own api',
'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;
}
});*/
// MODMAIL CODE //
client.on(Events.MessageCreate, async message => {
if (message.guild) return;
if (message.author.id === client.user.id) return;
if (!message.author.user) return;
const usesdata = await moduses.findOne({ User: message.author.id });
if (!usesdata) {
message.react('👋')
const modselect = new EmbedBuilder()
.setColor("White")
.setThumbnail("https://cdn.discordapp.com/avatars/1046468420037787720/5a6cfe15ecc9df0aa87f9834de38aa07.webp")
.setAuthor({ name: `📞 Modmail System`})
.setFooter({ text: `📞 Modmail Selecion`})
.setTimestamp()
.setTitle('> Select a Server')
.addFields({ name: `• Select a Modmail`, value: `> Please submit the Server's ID you are \n> trying to connect to in the modal displayed when \n> pressing the button bellow!`})
.addFields({ name: `• How do I get the server's ID?`, value: `> To get the Server's ID you will have to enable \n> Developer Mode through the Discord settings, then \n> you can get the Server's ID by right \n> clicking the Server's icon and pressing "Copy Server ID".`})
const button = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('selectmodmail')
.setLabel('• Select your Server')
.setStyle(ButtonStyle.Secondary)
)
const msg = await message.reply({ embeds: [modselect], components: [button] });
const selectcollector = msg.createMessageComponentCollector();
selectcollector.on('collect', async i => {
if (i.customId === 'selectmodmail') {
const selectmodal = new ModalBuilder()
.setTitle('• Modmail Selector')
.setCustomId('selectmodmailmodal')
const serverid = new TextInputBuilder()
.setCustomId('modalserver')
.setRequired(true)
.setLabel('• What server do you want to connect to?')
.setPlaceholder('Example: "1078641070180675665"')
.setStyle(TextInputStyle.Short);
const subject = new TextInputBuilder()
.setCustomId('subject')
.setRequired(true)
.setLabel(`• What's the reason for contacting us?`)
.setPlaceholder(`Example: "I wanted to bake some cookies, but toowake didn't let me!!!"`)
.setStyle(TextInputStyle.Paragraph);
const serveridrow = new ActionRowBuilder().addComponents(serverid)
const subjectrow = new ActionRowBuilder().addComponents(subject)
selectmodal.addComponents(serveridrow, subjectrow)
i.showModal(selectmodal)
}
})
} else {
if (message.author.bot) return;
const sendchannel = await client.channels.cache.get(usesdata.Channel);
if (!sendchannel) {
message.react('⚠')
await message.reply('**Oops!** Your **modmail** seems **corrupted**, we have **closed** it for you.')
return await moduses.deleteMany({ User: usesdata.User });
} else {
const msgembed = new EmbedBuilder()
.setColor("#ecb6d3")
.setAuthor({ name: `${message.author.username}`, iconURL: `${message.author.displayAvatarURL()}`})
.setFooter({ text: `📞 Modmail Message - ${message.author.id}`})
.setTimestamp()
.setDescription(`${message.content || `**No message provided.**`}`)
if (message.attachments.size > 0) {
try {
msgembed.setImage(`${message.attachments.first()?.url}`);
} catch (err) {
return message.react('❌')
}
}
const user = await sendchannel.guild.members.cache.get(usesdata.User)
if (!user) {
message.react('⚠️')
message.reply(`⚠️ You have left **${sendchannel.guild.name}**, your **modmail** was **closed**!`)
sendchannel.send(`⚠️ <@${message.author.id}> left, this **modmail** has been **closed**.`)
return await moduses.deleteMany({ User: usesdata.User })
}
try {
await sendchannel.send({ embeds: [msgembed] });
} catch (err) {
return message.react('❌')
}
message.react('📧')
}
}
})
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) return;
if (interaction.customId === 'selectmodmailmodal') {
const data = await moduses.findOne({ User: interaction.user.id });
if (data) return await interaction.reply({ content: `You have **already** opened a **modmail**! \n> Do **/modmail close** to close it.`, ephemeral: true });
else {
const serverid = interaction.fields.getTextInputValue('modalserver');
const subject = interaction.fields.getTextInputValue('subject');
const server = await client.guilds.cache.get(serverid);
if (!server) return await interaction.reply({ content: `**Oops!** It seems like that **server** does not **exist**, or I am **not** in it!`, ephemeral: true });
const executor = await server.members.cache.get(interaction.user.id);
if (!executor) return await interaction.reply({ content: `You **must** be a member of **${server.name}** in order to **open** a **modmail** there!`, ephemeral: true});
const modmaildata = await modschema.findOne({ Guild: server.id });
if (!modmaildata) return await interaction.reply({ content: `Specified server has their **modmail** system **disabled**!`, ephemeral: true});
const channel = await server.channels.create({
name: `modmail-${interaction.user.id}`,
parent: modmaildata.Category,
}).catch(err => {
return interaction.reply({ content: `I **couldn't** create your **modmail** in **${server.name}**!`, ephemeral: true});
})
await channel.permissionOverwrites.create(channel.guild.roles.everyone, { ViewChannel: false });
const embed = new EmbedBuilder()
.setColor("White")
.setThumbnail("https://cdn.discordapp.com/avatars/1046468420037787720/5a6cfe15ecc9df0aa87f9834de38aa07.webp")
.setAuthor({ name: `📞 Modmail System`})
.setFooter({ text: `📞 Modmail Opened`})
.setTimestamp()
.setTitle(`> ${interaction.user.username}'s Modmail`)
.addFields({ name: `• Subject`, value: `> ${subject}`})
const buttons = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('deletemodmail')
.setEmoji('❌')
.setLabel('Delete')
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId('closemodmail')
.setEmoji('🔒')
.setLabel('Close')
.setStyle(ButtonStyle.Secondary)
)
await moduses.create({
Guild: server.id,
User: interaction.user.id,
Channel: channel.id
})
await interaction.reply({ content: `Your **modmail** has been opened in **${server.name}**!`, ephemeral: true});
const channelmsg = await channel.send({ embeds: [embed], components: [buttons] });
channelmsg.createMessageComponentCollector();
}
}
})
client.on(Events.InteractionCreate, async interaction => {
if (interaction.customId === 'deletemodmail') {
const closeembed = new EmbedBuilder()
.setColor("White")
.setThumbnail("https://cdn.discordapp.com/avatars/1046468420037787720/5a6cfe15ecc9df0aa87f9834de38aa07.webp")
.setAuthor({ name: `📞 Modmail System`})
.setFooter({ text: `📞 Modmail Closed`})
.setTimestamp()
.setTitle('> Your modmail was Closed')
.addFields({ name: `• Server`, value: `> ${interaction.guild.name}`})
const delchannel = await interaction.guild.channels.cache.get(interaction.channel.id);
const userdata = await moduses.findOne({ Channel: delchannel.id });
await delchannel.send('❌ **Deleting** this **modmail**..')
setTimeout(async () => {
if (userdata) {
const executor = await interaction.guild.members.cache.get(userdata.User)
if (executor) {
await executor.send({ embeds: [closeembed] });
await moduses.deleteMany({ User: userdata.User });
}
}
try {
await delchannel.delete();
} catch (err) {
return;
}
}, 100)
}
if (interaction.customId === 'closemodmail') {
const closeembed = new EmbedBuilder()
.setColor("White")
.setThumbnail("https://cdn.discordapp.com/avatars/1046468420037787720/5a6cfe15ecc9df0aa87f9834de38aa07.webp")
.setAuthor({ name: `📞 Modmail System`})
.setFooter({ text: `📞 Modmail Closed`})
.setTimestamp()
.setTitle('> Your modmail was Closed')
.addFields({ name: `• Server`, value: `> ${interaction.guild.name}`})
const clchannel = await interaction.guild.channels.cache.get(interaction.channel.id);
const userdata = await moduses.findOne({ Channel: clchannel.id });
if (!userdata) return await interaction.reply({ content: `🔒 You have **already** closed this **modmail**.`, ephemeral: true})
await interaction.reply('🔒 **Closing** this **modmail**..')
setTimeout(async () => {
const executor = await interaction.guild.members.cache.get(userdata.User)
if (executor) {
try {
await executor.send({ embeds: [closeembed] });
} catch (err) {
return;
}
}
interaction.editReply(`🔒 **Closed!** <@${userdata.User}> can **no longer** view this **modmail**, but you can!`)
await moduses.deleteMany({ User: userdata.User });
}, 100)
}
})
client.on(Events.MessageCreate, async message => {
if (message.author.bot) return;
if (!message.guild) return;
const data = await modschema.findOne({ Guild: message.guild.id });
if (!data) return;
const sendchanneldata = await moduses.findOne({ Channel: message.channel.id });
if (!sendchanneldata) return;
const sendchannel = await message.guild.channels.cache.get(sendchanneldata.Channel);
const member = await message.guild.members.cache.get(sendchanneldata.User);
if (!member) return await message.reply(`⚠ <@${sendchanneldata.User} is **not** in your **server**!`)
const msgembed = new EmbedBuilder()
.setColor("White")
.setThumbnail("https://cdn.discordapp.com/avatars/1046468420037787720/5a6cfe15ecc9df0aa87f9834de38aa07.webp")
.setAuthor({ name: `${message.author.username}`, iconURL: `${message.author.displayAvatarURL()}`})
.setFooter({ text: `📞 Modmail Received - ${message.author.id}`})
.setTimestamp()
.setDescription(`${message.content || `**No message provided.**`}`)
if (message.attachments.size > 0) {
try {
msgembed.setImage(`${message.attachments.first()?.url}`);
} catch (err) {
return message.react('❌')
}
}
try {
await member.send({ embeds: [msgembed] });
} catch (err) {
message.reply(`⚠ I **couldn't** message **<@${sendchanneldata.User}>**!`)
return message.react('❌')
}
message.react('📧')
})
///prefix system
/// suops dev stuff
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', () => {
console.log(`Logged in as ${client.user.tag}`);
});
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: 'Image',
},
{
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',
},
// Add more commands as needed
];
const groupByCategory = commandsList.reduce((result, command) => {
const category = command.category.toLowerCase() || 'uncategorized';
if (!result[category]) {
result[category] = [];
}
result[category].push(command);
return result;
}, {});
client.on('messageCreate', async (message) => {
if (message.content.toLowerCase() === '?help') {
const categories = Object.keys(groupByCategory);
const embed = new EmbedBuilder()
.setColor('#3498db')
.setTitle('Command Categories')
.setDescription('List of available command categories:')
.addFields(categories.map((category) => {
return { name: category.charAt(0).toUpperCase() + category.slice(1), value: `\`${category}\``, inline: true };
}));
message.channel.send({ embeds: [embed] });
} else if (message.content.toLowerCase().startsWith('?help')) {
const requestedCategory = message.content.toLowerCase().split('?help ')[1].trim();
const category = Object.keys(groupByCategory).find(
(key) => key === requestedCategory || key.charAt(0).toUpperCase() + key.slice(1) === requestedCategory
);
if (!category) {
message.reply('Category not found.');
return;
}
const commands = groupByCategory[category];
const embed = new EmbedBuilder()
.setColor('#3498db')
.setTitle(`${category.charAt(0).toUpperCase() + category.slice(1)} Commands`)
.setDescription(`List of commands under ${category}:`)
.addFields(commands.map((command) => {
return { name: command.name, value: `**Description:** ${command.description}\n**Usage:** ${command.usage}` };
}));
message.channel.send({ embeds: [embed] });
} else if (message.content.toLowerCase().startsWith('?translate')) {
// Implement translation logic here
// Extract text and target language from message content
// Perform translation and send the translated text as a MessageEmbed
// For example:
// message.channel.send('Translated text: TranslatedTextHere');
message.channel.send('Translation command is under construction.');
} else if (message.content.toLowerCase().startsWith('?slowmode')) {
// Implement slow mode logic here
// Extract the slow mode time from message content
// Set slow mode for the channel and send a confirmation message
// For example:
// message.channel.setRateLimitPerUser(10); // 10 seconds slow mode
message.channel.send('Slow mode command is under construction.');
}
});
//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')) {
return message.reply('You do not have permission to use this command.');
}
const seconds = parseInt(args[1]);
if (!seconds || isNaN(seconds)) {
return message.reply('Please provide a valid number of seconds for slow mode.');
}
if (seconds < 0 || seconds > 21600) {
return message.reply('Slow mode duration must be between 0 and 21600 seconds (6 hours).');
}
try {
await message.channel.setRateLimitPerUser(seconds);
message.reply(`Slow mode set to ${seconds} seconds.`);
} catch (error) {
console.error('Error setting slow mode:', error);
message.reply('An error occurred while setting slow mode.');
}
}
});
// brain shop ai
client.on('messageCreate', async message => {
if (!message.guild) return; // Ignore messages from DMs
if (message.author.bot) return; // Ignore messages from bots
if (message.content.startsWith(`${prefix}ask`)) {
const prompt = message.content.slice(`${prefix}ask`.length).trim();
try {
const url = `${config.brainShopApiUrl}?bid=${config.brainShopBotId}&key=${config.brainShopApiKey}&uid=1&msg=${encodeURIComponent(prompt)}`; // No need to change these. They are already defined in config.json
const response = await fetch(url);
if (response.ok) {
const data = await response.json();
const answer = data.cnt;
await message.reply(`The AI says: ${answer}`);
} else {
throw new Error('Failed to fetch data from BrainShop API');
}
} catch (error) {
console.error('Error occurred:', error);
await message.reply('An error occurred while processing your request.');
}
}
});
//prefix system
//prefix system/////////////////////////////////
// Create a Map to store the server prefixes
const prefixes = new Map();
// Function to retrieve the server prefix
const getPrefix = (guildId) => {
return prefixes.get(guildId) || '';
};
// Load the prefix commands from the "prefixcommands" folder
client.prefixcommands = new Collection();
const prefixCommandFiles = fs.readdirSync('./prefixcommands').filter(file => file.endsWith('.js'));
for (const file of prefixCommandFiles) {
const command = require(`./prefixcommands/${file}`);
client.prefixcommands.set(command.nombre, command);
}
// Rest of your code...
client.on('messageCreate', async (message) => {
// Ignore messages from bots and non-text channels
if (message.author.bot || !message.guild) return;
// Retrieve the server prefix
const prefix = getPrefix(message.guild.id);
// Check if the message starts with the prefix
if (!message.content.startsWith(prefix)) return;
// Extract the command and arguments
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
// Check if the command exists in the prefix commands collection
if (client.prefixcommands.has(commandName)) {
const command = client.prefixcommands.get(commandName);
try {
// Execute the command
command.run(client, message, args);
} catch (error) {
console.error(error);
message.reply('An error occurred while executing the command.');
}
}
});
// If you want to enable the auto mod command (bad words) uncomment this section (You can config the words and message in config.json)
/* client.on('messageCreate', async (message) => {
const lowerCaseContent = message.content.toLowerCase(); // Lowercase the message content for better matching
if (config.badWords.some(word => lowerCaseContent.includes(word))) {
try {
const warningMessage = await message.reply(config.warningMessage);
setTimeout(() => {
warningMessage.delete().catch(console.error); // Delete the warning message after a short delay
}, 5000); // 5000 milliseconds (5 seconds)
await message.delete(); // Delete the message containing the swear word
} catch (error) {
console.error('Error:', error);
}
}
}); */
//////pend///
/////games 1v1/////
const levelNames2 = ["Unranked", "Bronze", "Silver", "Gold", "Emerald", "Diamond", "Master", "Elite"];
const discordTranscripts = require('discord-html-transcripts');
const duelsSchema = require('./Schemas/1v1Schema');
const duelsLevelSchema = require("./Schemas/1v1Levels");
const chatSchema = require('./Schemas/chat');
client.on(Events.InteractionCreate, async i => {
if (i.isButton()) {
if (i.customId === 'queue') {
const duelsData = await duelsSchema.findOne({ Guild: i.guild.id })
if (!duelsData) {
i.reply({ content: "The 1v1 system is currently disabled.", ephemeral: true})
return;
}
const category = i.guild.channels.cache.get(duelsData.Category)
const logChannel = i.guild.channels.cache.get(duelsData.Logs)
const transcriptsChannel = i.guild.channels.cache.get(duelsData.Transcript)
const member = i.member
if (!member) {
i.reply({ content: "This command can only be used by guild members.", ephemeral: true });
return;
}
const username = member.user.username.toLowerCase();
const channelName = username.replace(/ /g, "-");
const posChannel = await i.guild.channels.cache.find(c => c.name.includes(username) || c.name.includes(channelName));
const openMatchmakingEmbed = new EmbedBuilder()
.setColor("Green")
.setAuthor({
name: "Match Open 🎮",
iconURL: client.user.avatarURL({ dynamic: true, size: 1024 })
})
.setDescription(`You are already in a match there for you cannot queue again! Wait until your match has been played out!`)
.setTimestamp()
.setFooter({ text: `Radiant Utilities | Matchmaking System`})
const dmEmbed = new EmbedBuilder()
.setColor("Green")
.setAuthor({
name: "Matchmaking Queue 🎮",
iconURL: client.user.avatarURL({ dynamic: true, size: 1024 })
})
.setDescription(`You were added to the matchmaking queue. You can leave this queue at any time by clicking the 'unqueue' button on the queue message.`)
.setTimestamp()
.setFooter({ text: `Radiant Utilities | Matchmaking System`})
if (posChannel) return await i.reply({ embeds: [openMatchmakingEmbed], ephemeral: true})
const Data2 = await duelsLevelSchema.findOne({ Guild: i.guild.id, User: member.id });
if (!Data2) {
duelsLevelSchema.create({
Guild: i.guild.id,
User: member.id,
Rank: 0,
Level: 0
})
}
const Data = await duelsSchema.findOne({ Guild: i.guild.id, MatchID: 0 });
if (!Data) {
duelsSchema.create({
Guild: i.guild.id,
MatchID: 0,
MemberOneID: member.id,
UserID: 0
})
i.reply({ content: ":white_check_mark: You were added to the queue!", ephemeral: true })
member.send({ embeds: [dmEmbed] }).catch(err => {
return;
})
const queueEmbed = new EmbedBuilder()
.setColor("Aqua")
.setAuthor({
name: "Entered Queue",
iconURL: client.user.avatarURL({ dynamic: true, size: 1024 })
})
.setDescription(`${member} has enterd the queue`)
.setTimestamp()
.setFooter({ text: "Radiant Utilities | Matchmaking System"})
logChannel.send({ embeds: [queueEmbed] })
} else if (Data.MemberOneID != member.id) {
const memberTwo = member
const guild = i.guild
if (!guild) return console.log(`Couldn't find guild with ID ${guild}`);
const memberOne = guild.members.cache.get(Data.MemberOneID);
if (!memberOne) return i.reply({ content: 'The 1v1 queuing system is down for maintenance.' });
const channel = await i.guild.channels.create({
name: `1v1 ${memberOne.user.username} vs ${memberTwo.user.username}`,
type: ChannelType.GuildText,
parent: category
}).catch(err => {
i.reply({ content: 'The 1v1 queuing system is down for maintenance.' })
})
await duelsSchema.deleteMany({
Guild: i.guild.id,
MemberOneID: memberOne.id
});
const queueEmbed = new EmbedBuilder()
.setColor("Blue")
.setAuthor({
name: "Entered Queue",
iconURL: client.user.avatarURL({ dynamic: true, size: 1024 })
})
.setDescription(`${memberTwo} has enterd the queue`)
.setTimestamp()
.setFooter({ text: "Radiant Utilities | Matchmaking System"})
const guildMemberOne = await channel.guild.members.fetch(memberOne.id).catch(() => null);
if (!guildMemberOne) {
return;
} else {
channel.permissionOverwrites.create(memberOne, { ViewChannel: true, SendMessages: true });
}
const guildMemberTwo = await channel.guild.members.fetch(memberTwo.id).catch(() => null);
if (!guildMemberTwo) {
return;
} else {
channel.permissionOverwrites.create(memberTwo, { ViewChannel: true, SendMessages: true });
}
i.reply({ content: `:white_check_mark: You were added to the queue! You can see it here: ${channel}`, ephemeral: true })
memberTwo.send({ embeds: [dmEmbed] }).catch(err => {
return;
})
memberOne.send(`Hey ${memberOne}, your 1v1 has started, you are going against ${memberTwo}, you can view it here: ${channel}. Good luck!`).catch(err => {
return;
});
memberTwo.send(`Hey ${memberTwo}, your 1v1 has started, you are going against ${memberOne}, you can view it here: ${channel}. Good luck!`).catch(err => {
return;
});
if (logChannel) {
await logChannel.send({ embeds: [queueEmbed] });
} else {
return;
}
const logEmbed = new EmbedBuilder()
.setColor('Green')
.setAuthor({
name: "New Match Started",
iconURL: client.user.avatarURL({ dynamic: true, size: 1024 })
})
.setDescription(`Match started between ${memberOne} and ${memberTwo}`)
.setTimestamp()
.setFooter({ text: "Radiant Utilities | Matchmaking System"})
if (logChannel) {
await logChannel.send({ embeds: [logEmbed] })
} else {
return;
}
const levelData = await duelsLevelSchema.findOne({ Guild: i.guild.id, User: memberOne.id});
const levelData2 = await duelsLevelSchema.findOne({ Guild: i.guild.id, User: memberTwo.id });