-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
142 lines (99 loc) · 3.68 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
require('dotenv').config();
const { Client, IntentsBitField, Collection} = require('discord.js');
const fs = require('fs');
const {prefix} = require('./config.json');
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
});
client.once('ready', () => {
console.log('Bot is ready!');
changeStatus();
setInterval(changeStatus, 60000);
});
function changeStatus() {
const statusOptions = [`with Jox`,'Music','and helping', 'do for .help', `in ${client.guilds.cache.size} servers`];
const randomOption = statusOptions[Math.floor(Math.random() * statusOptions.length)];
client.user.setPresence({
activities: [{ name: `${randomOption}` }],
});
}
//Command Scanner
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
setTimeout(() => {
message.delete().catch(console.error);
}, 30000);
});
client.commands = new Collection();
//Dev
const devFiles = fs.readdirSync('./dev').filter(file => file.endsWith('.js'));
for (const file of devFiles) {
const command = require(`./dev/${file}`);
client.commands.set(command.name, command);
}
//Fun
const funFiles = fs.readdirSync('./fun').filter(file => file.endsWith('.js'));
for (const file of funFiles) {
const command = require(`./fun/${file}`);
client.commands.set(command.name, command);
}
//Utils
const utilsFiles = fs.readdirSync('./utils').filter(file => file.endsWith('.js'));
for (const file of utilsFiles) {
const command = require(`./utils/${file}`);
client.commands.set(command.name, command);
}
//Moderation
const moderationFiles = fs.readdirSync('./moderation').filter(file => file.endsWith('.js'));
for (const file of moderationFiles) {
const command = require(`./moderation/${file}`);
client.commands.set(command.name, command);
}
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 (!client.commands.has(command)) return;
try {
client.commands.get(command).execute(message, args);
} catch (error) {
console.error(error);
}
});
//Bug Report System
const { EmbedBuilder } = require('discord.js');
client.on('messageCreate', async (message) => {
if (message.author.bot || !message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'br') {
const guildId = (process.env.GI);
const channelId = (process.env.CI);
const targetGuild = client.guilds.cache.get(guildId);
if (!targetGuild) {
return message.reply('Target guild not found. Please provide a valid guild ID.');
}
const targetChannel = targetGuild.channels.cache.get(channelId);
if (!targetChannel) {
return message.reply('Target channel not found. Please provide a valid channel ID.');
}
const messageContent = args.join(' ');
const user = message.author;
const bugEmbed = new EmbedBuilder()
.setColor('#FF0000')
.setAuthor({
name: message.author.username,
iconURL: user.displayAvatarURL()
})
.setDescription(`**Server:** ${message.guild.name}\n**Bug:** ${messageContent}`);
await targetChannel.send({ embeds: [bugEmbed] });
message.reply('Bug sent successfully!').then(msg => msg.delete({ timeout:10000 }));
}
});
client.login(process.env.TOKEN);