-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (39 loc) · 1.41 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
const { configDotenv } = require('dotenv');
configDotenv();
const client = require('./core/client');
const { Events } = require('discord.js');
const { checkVoiceChannels, connectToChannel } = require('./handlers/voice');
const { joinAndListen } = require('./handlers/speechHandler');
const { initializeSodium, initializeVoskModel } = require('./utils/voskUtils');
const { printDependencyReport } = require('./utils/audioUtils');
const { discordToken } = require('./core/config');
let currentChannel = null;
// Initialize dependencies
(async () => {
await initializeSodium();
await initializeVoskModel();
printDependencyReport();
})();
client.once(Events.ClientReady, () => {
console.log('Bot is ready!');
checkVoiceChannels(client, currentChannel, setCurrentChannel, (channel) => joinAndListen(channel, connectToChannel));
});
client.login(discordToken);
// Utility to set the current channel
function setCurrentChannel(channel) {
currentChannel = channel;
}
// Prevent the bot from exiting unexpectedly
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
process.on('uncaughtException', error => {
console.error('Uncaught exception:', error);
});
process.on('SIGINT', () => {
console.log('SIGINT signal received: closing HTTP server');
process.exit(0);
});
process.on('exit', (code) => {
console.log(`Process exited with code: ${code}`);
});