forked from Mikasuru/KukuriClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.js
66 lines (58 loc) · 2.25 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
const { Client } = require('discord.js-selfbot-v13');
const fs = require('fs');
const path = require('path');
const Config = require("./Config/Config.json");
const scheduleCommand = require('./Commands/Schedule');
const client = new Client({
checkUpdate: false
});
client.commands = new Map();
function loadCommands() {
const commandsPath = path.join(__dirname, 'Commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
let loadedCount = 0;
console.log('Loading commands...');
for (const file of commandFiles) {
try {
const command = require(path.join(commandsPath, file));
client.commands.set(command.name, command);
if (Config.GeneralSettings.ShowLoadCommands == true) {
console.log(`✅: ${command.name}`);
}
loadedCount++;
} catch (error) {
console.error(`❌: ('${file}') - `, error.message);
}
}
console.log(`${loadedCount} Command(s) loaded successfully.`);
}
client.on('ready', async () => {
loadCommands();
console.log(`Logged as ${client.user.tag}`);
scheduleCommand.initialize(client);
for (const command of client.commands.values()) {
if (command.onReady) {
await command.onReady(client);
}
}
// TODO: Make a startup message if bot starting up
});
client.on('messageCreate', async (message) => {
try {
const prefix = Config.BotSettings.Prefix || '.';
if (message.author.id !== Config.GeneralSettings.OwnerID && !Config.BotSettings.BotAdmins.includes(message.author.id)) {
return; // return if not an owner or admin
}
if (!message.author.bot && message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName);
if (command) {
await command.execute(message, args, client);
}
}
} catch (error) {
console.error('Error handling command:', error);
}
});
client.login(Config.BotSettings.Token);