This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathIndex.js
More file actions
46 lines (37 loc) · 1.45 KB
/
Index.js
File metadata and controls
46 lines (37 loc) · 1.45 KB
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
const { ClusterClient, getInfo } = require("discord-hybrid-sharding");
const { Client, GatewayIntentBits, Partials, Collection } = require("discord.js");
const errorHandler = require('./handlers/errorHandler');
const { checkAndRemoveBans } = require('./events/jobs/unbanJob');
require("dotenv").config();
const { Guilds, GuildMembers, GuildMessages, MessageContent, GuildVoiceStates } = GatewayIntentBits;
const { User, Message, GuildMember, ThreadMember, Channel } = Partials;
const { loadEvents } = require("./handlers/eventHandler");
const { loadCommands } = require("./handlers/commandHandler");
const client = new Client({
shards: getInfo().SHARD_LIST,
shardCount: getInfo().TOTAL_SHARDS,
intents: [Guilds, GuildMembers, GuildMessages, MessageContent, GuildVoiceStates],
partials: [User, Message, GuildMember, ThreadMember],
});
client.commands = new Collection();
client.cluster = new ClusterClient(client);
setInterval(() => {
checkAndRemoveBans(client);
}, 15000);
async function initializeBot() {
try {
await client.login(process.env.token);
await loadEvents(client);
await loadCommands(client);
console.log('Bot is ready!');
await errorHandler.initializeLogFile();
} catch (error) {
console.error('Failed to initialize bot:', error);
errorHandler.logError(error, { context: 'Bot Initialization' });
process.exit(1);
}
}
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
initializeBot();