-
Notifications
You must be signed in to change notification settings - Fork 0
/
magmastream.js
37 lines (31 loc) · 995 Bytes
/
magmastream.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
const { readdirSync } = require("fs");
const { Manager } = require("magmastream");
const nodes = require("./config.json")
module.exports = class Magmastream extends Manager {
constructor(client) {
super({
nodes: nodes.nodes,
autoPlay: true,
defaultSearchPlatform: "soundcloud",
replaceYouTubeCredentials: true,
clientName: "UltimateTunes",
send: (id, payload) => this._sendPayload(id, payload),
});
this.client = client;
this._loadMagmastreamEvents();
}
_sendPayload(id, payload) {
const guild = this.client.guilds.cache.get(id);
if (guild) return guild.shard.send(payload);
}
_loadMagmastreamEvents() {
let i = 0;
readdirSync("./Magmastream").forEach((file) => {
const event = require(`./Magmastream/${file}`);
const eventName = file.split(".")[0];
this.on(eventName, event.bind(null, this.client));
++i;
});
console.log(`Loaded a total of ${i} Magmastream event(s)`);
}
};