-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
72 lines (60 loc) · 2.92 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// ChadMusic - The Chad Music Bot
/// Copyright (C) 2025 Micky | 200percentmicky
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program. If not, see <https://www.gnu.org/licenses/>.
/* Index File */
require('dotenv').config();
const { ClusterManager } = require('discord-hybrid-sharding');
const logger = require('./src/lib/ChadLogger.js');
if (process.versions.node.split('.')[0] < 18) {
logger.error(`ChadMusic requires Node.js 18 or later. You currently have ${process.versions.node} installed. Please update your Node.js installation.`);
process.exit(1);
}
// Say hello!
const { version } = require('./package.json');
logger.info(' ________ ____ ___ _');
logger.info(' / ____/ /_ ____ _____/ / |/ /_ _______(_)____');
logger.info(' / / / __ \\/ __ `/ __ / /|_/ / / / / ___/ / ___/');
logger.info('/ /___/ / / / /_/ / /_/ / / / / /_/ (__ ) / /__');
logger.info('\\____/_/ /_/\\__,_/\\__,_/_/ /_/\\__,_/____/_/\\___/');
logger.info('/////////////// The Chad Music Bot! ///////////////');
logger.info('Created by Micky | @200percentmicky');
logger.info(`Bot Version: ${version}`);
logger.info('Loading libraries...');
if (process.env.YOUTUBE_COOKIE) {
logger.warn('YOUTUBE_COOKIE environment variable has been deprecated. Please switch to the new cookie format by following the instructions at https://distube.js.org/#/docs/DisTube/main/general/cookie. Paste the new cookie in the cookies.json file.');
}
if (process.env.SHARDING) {
logger.info('Starting client with sharding enabled.');
const manager = new ClusterManager('./src/bot.js', {
totalShards: parseInt(process.env.SHARDS) ?? 'auto',
shardsPerClusters: parseInt(process.env.SHARDS_PER_CLUSTER) ?? 2,
mode: 'process'
});
if (manager.totalShards === 'auto') {
manager.token = process.env.TOKEN;
}
manager.on('clusterCreate', c => logger.info(`Cluster ${c.id} launched.`))
.on('clusterReady', c => logger.info(`Cluster ${c.id} is ready.`));
manager.spawn({ timeout: -1 });
} else {
logger.info('Starting client with sharding disabled.');
const ChadMusic = require('./src/bot.js');
try {
new ChadMusic().login(process.env.TOKEN);
} catch (err) {
logger.fatal(`ChadMusic failed to start! :(\n${err.stack}`);
process.exit(1);
}
}