forked from GlaceYT/Multi-Musix-ADV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
130 lines (100 loc) · 4.15 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const fs = require('fs');
const path = require('path');
const { Player } = require('discord-player');
const express = require('express');
require('dotenv').config();
const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a];
}),
});
const { printWatermark } = require('./functions/handlers');
const configPath = './config.json';
const configData = JSON.parse(fs.readFileSync(configPath));
const prefix = configData.prefix;
const app = express();
const port = 3000;
app.get('/', (req, res) => {
const imagePath = path.join(__dirname, 'index.html');
res.sendFile(imagePath);
});
app.listen(port, () => {
console.log(`🔗 Listening to GlaceYT : http://localhost:${port}`);
});
printWatermark();
client.commands = new Map();
const funCommandsPath = path.join(__dirname, 'funCommands');
const animeCommandsPath = path.join(__dirname, 'AnimeCommands');
const utilityCommandsPath = path.join(__dirname, 'utilityCommands');
const imageCommandsPath = path.join(__dirname, 'imageCommands');
const basicCommandsPath = path.join(__dirname, 'basicCommands');
const animeCommandFiles = fs.readdirSync(animeCommandsPath).filter((file) => file.endsWith('.js'));
const funCommandFiles = fs.readdirSync(funCommandsPath).filter((file) => file.endsWith('.js'));
const utilityCommandFiles = fs.readdirSync(utilityCommandsPath).filter((file) => file.endsWith('.js'));
const imageCommandFiles = fs.readdirSync(imageCommandsPath).filter((file) => file.endsWith('.js'));
const basicCommandFiles = fs.readdirSync(basicCommandsPath).filter((file) => file.endsWith('.js'));
for (const file of funCommandFiles) {
const command = require(path.join(funCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of animeCommandFiles) {
const command = require(path.join(animeCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of utilityCommandFiles) {
const command = require(path.join(utilityCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of imageCommandFiles) {
const command = require(path.join(imageCommandsPath, file));
client.commands.set(command.name, command);
}
for (const file of basicCommandFiles) {
const command = require(path.join(basicCommandsPath, 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 commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName);
if (!command) return;
try {
command.execute(message, args);
} catch (error) {
console.error(error);
message.reply('There was an error trying to execute that command!');
}
});
async function login() {
try {
await client.login(process.env.TOKEN);
console.log('\x1b[32m%s\x1b[0m', '| 🍔 Bot logged in successfully!');
console.log('\x1b[36m%s\x1b[0m', '| 🚀 Commands Loaded successfully!');
console.log('\x1b[32m%s\x1b[0m', `| 🌼 Logged in as ${client.user.username}`);
console.log('\x1b[36m%s\x1b[0m', `| 🏡 Bot is in ${client.guilds.cache.size} servers`);
} catch (error) {
console.error('\x1b[31m%s\x1b[0m', '❌ Failed to log in:', error);
console.log('\x1b[31m%s\x1b[0m', '❌ Client Not Login, Restarting Process...');
process.kill(1);
}
}
client.once('ready', () => {
setTimeout(() => {
console.log('\x1b[32m%s\x1b[0m', `| 🎯 Activity sucessfully set!`);
client.user.setPresence({
activities: [{ name: `[email protected]`, type: ActivityType.Watching }],
status: 'idle',
});
}, 2000);
});
login();
setInterval(() => {
if (!client || !client.user) {
console.log('\x1b[31m%s\x1b[0m', '❌ Client Not Logged in, Restarting Process...');
process.kill(1);
}
}, 15000);
module.exports = client;