-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
68 lines (60 loc) · 2.16 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
const { Client, GatewayIntentBits, Collection, EmbedBuilder } = require("discord.js");
const { FerraLink } = require("ferra-link");
const { Connectors } = require("shoukaku");
const config = require("./config.js");
const fs = require("fs");
const client = new Client({intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
]});
client.commands = new Collection();
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith("js"));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
client.on(file.split(".")[0], (...args) => event(client, ...args));
}
const commandFiles = fs.readdirSync(`./commands`).filter(file => file.endsWith("js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
};
//ferralink
client.manager = new FerraLink({
nodes: config.nodes,
shoukakuoptions: config.shoukakuOptions,
spotify: [{
ClientID: config.spotify.clientID,
ClientSecret: config.spotify.clientSecret
}],
defaultSearchEngine: "FerralinkSpotify",
}, new Connectors.DiscordJS(client));
const ferralink = client.manager;
ferralink.shoukaku.on("ready", (name) => {
console.log(`Node ${name} connected`);
});
ferralink.on("trackStart", (player, track) => {
const channel = client.channels.cache.get(player.textId);
const embed = new EmbedBuilder()
.setTitle("🎶 Now Playing")
.setColor("Random")
.setDescription(`[${track.info.title}](${track.info.uri}) [${track.info.requester}]`);
channel.send({embeds: [embed]});
});
ferralink.on("queueEnd", (player) => {
const channel = client.channels.cache.get(player.textId);
const embed = new EmbedBuilder()
.setColor("Red")
.setDescription("Queue has ended.");
channel.send({embeds: [embed]});
return player.destroy();
});
process.on("unhandledRejection", (reason, promise) => {
try {
console.error("Unhandled Rejection at: ", promise, "reason: ", reason.stack || reason);
} catch {
console.error(reason);
}
});
client.login(config.token);