-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
56 lines (38 loc) · 1.3 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
/*******************************************************
* Copyright (C) 2023-2024 notaisar <[email protected]>
*
* This file is part of insight bot.
*
* insight bot can not be copied and/or distributed without the express
* permission of notaisar
*******************************************************/
const express = require('express');
const { ShardingManager, GatewayIntentBits, Partials, Collection, Events } = require('discord.js');
const noblox = require('noblox.js');
const fs = require('fs');
const path = require('path');
const app = express();
const manager = new ShardingManager(path.join(__dirname, 'bot.js'), { token: process.env.TOKEN });
app.use(express.static('public'));
app.get('/', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
});
app.listen(process.env.PORT || 3000, () => {
console.log('server started');
});
manager.on('shardCreate', shard => {
console.log(`shard ${shard.id} launched`);
});
manager.spawn();
// error handling
manager.on('error', error => {
console.log('Sharding manager error:', error);
});
// handle uncaught exceptions
process.on('uncaughtException', error => {
console.log('Uncaught exception:', error);
});
// handle unhandled rejections
process.on('unhandledRejection', error => {
console.log('Unhandled rejection:', error);
});