This repository was archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMelodyTune.js
98 lines (80 loc) · 2.61 KB
/
MelodyTune.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* @require Declare global and including all require library's.
*/
const { readdirSync } = require('fs'),
{ Client, Collection, Intents, Options} = require('discord.js'),
{ Manager } = require('erela.js'),
Spotify = require('better-erela.js-spotify').default;
require('dotenv').config();
/**
* @Check for anticrash with all process error events.
*/
try {
require('./util/process');
} catch {
console.warn('[Warning] Process rejections not specified.');
}
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES
],
makeCache: Options.cacheWithLimits({
UserManager: 0,
StageInstanceManager: 0,
ApplicationCommandManager: 100,
ThreadManager: 0,
ThreadMemberManager: 0
}),
presence: {
activities: [
{
name: 'What\'s this?'
}
]
}
});
/**
* Setting up discord.js collection to cache.
*/
client.slashCommands = new Collection();
client.defcolor = '#1d7ef5';
client.errcolor = '#cf1f3c';
client.config = require('./json/nodes.json');
client.setMaxListeners(0);
/**
* Setting up lavalink manager class.
*/
client.manager = new Manager({
nodes: client.config.lavanodes.nodes,
send: (id, payload) => {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
},
autoPlay: true,
plugins: [
new Spotify({
clientID: process.env.SpotifyClientID || new Error('[Error] You need to specify Spotify client ID.'),
clientSecret: process.env.SpotifyClientSecret || new Error('[Error] You need to specify Spotify client secret.')
})
]
});
/* Send raw data */
client.on('raw', (raw) => client.manager.updateVoiceState(raw));
const djsEvents = readdirSync('./events/client').filter(f => f.endsWith('.js'));
for (const file of djsEvents) {
console.log(`Loading discord.js event: ${file}`);
const event = require(`./events/client/${file}`);
client.on(file.split('.')[0], event.bind(null, client));
};
/**
* Loading erela.js events
*/
const player = readdirSync('./events/lavalink').filter(f => f.endsWith('.js'));
for (const file of player) {
console.log(`Loading erela.js event: ${file}`);
const event = require(`./events/lavalink/${file}`);
client.manager.on(file.split('.')[0], event.bind(null, client));
};
/* Load and register all slash commands */
client.login(process.env.Token || new Error('[Error] You need to specify bot token.'));