aqualink 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# AquaLink
|
|
2
|
+
An Stable, performant, Recourse friendly and fast lavalink wrapper
|
|
3
|
+
|
|
4
|
+
This code is based in riffy, but its an 100% Rewrite made from scratch...
|
|
5
|
+
|
|
6
|
+
# Why use AquaLink
|
|
7
|
+
- In dev
|
|
8
|
+
- Very Low memory comsuption
|
|
9
|
+
- Built in Queue manager
|
|
10
|
+
- Lots of features to use
|
|
11
|
+
- Lowest CPU Usage
|
|
12
|
+
- Very fast (mine take less than 1 second to load an song!)
|
|
13
|
+
- 1 Player created = ~1 - 0,8 mb per player
|
|
14
|
+
- Auto clean Up memory when song finishes / bot leave the vc
|
|
15
|
+
- Plugin system
|
|
16
|
+
- Lavalink v4 support (din't test v3)
|
|
17
|
+
- Youtube and Spotify support
|
|
18
|
+
- Minimal Requests to the lavalink server (helps the lavalink recourses!)
|
|
19
|
+
|
|
20
|
+
# How to install (Not avalible yet)
|
|
21
|
+
|
|
22
|
+
```npm install aqualink```
|
|
23
|
+
|
|
24
|
+
`pnpm install aqualink`
|
|
25
|
+
|
|
26
|
+
# Basic usage (Not 100% functional yet)
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const { Aqua } = require("./build/index.js");
|
|
30
|
+
const { Client, Collection, GatewayDispatchEvents } = require("discord.js");
|
|
31
|
+
|
|
32
|
+
const client = new Client({
|
|
33
|
+
intents: [
|
|
34
|
+
"Guilds",
|
|
35
|
+
"GuildMembers",
|
|
36
|
+
"GuildMessages",
|
|
37
|
+
"MessageContent",
|
|
38
|
+
"GuildVoiceStates"
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const nodes = [
|
|
43
|
+
{
|
|
44
|
+
host: "127.0.0.1",
|
|
45
|
+
password: "yourpass",
|
|
46
|
+
port: 233,
|
|
47
|
+
secure: false,
|
|
48
|
+
name: "localhost"
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const aqua = new Aqua(client, nodes, {
|
|
53
|
+
send: (payload) => {
|
|
54
|
+
const guild = client.guilds.cache.get(payload.d.guild_id);
|
|
55
|
+
if (guild) guild.shard.send(payload);
|
|
56
|
+
},
|
|
57
|
+
defaultSearchPlatform: "ytsearch",
|
|
58
|
+
restVersion: "v4"
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
client.aqua = aqua;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
client.once("ready", () => {
|
|
66
|
+
client.aqua.init(client.user.id);
|
|
67
|
+
console.log("Ready!");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
client.on("raw", (d) => {
|
|
72
|
+
if (![GatewayDispatchEvents.VoiceStateUpdate, GatewayDispatchEvents.VoiceServerUpdate,].includes(d.t)) return;
|
|
73
|
+
client.aqua.updateVoiceState(d);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
client.on("messageCreate", async (message) => {
|
|
77
|
+
if (message.author.bot) return;
|
|
78
|
+
|
|
79
|
+
if (!message.content.startsWith("!play")) return;
|
|
80
|
+
|
|
81
|
+
const query = message.content.slice(6);
|
|
82
|
+
|
|
83
|
+
const player = client.aqua.createConnection({
|
|
84
|
+
guildId: message.guild.id,
|
|
85
|
+
voiceChannel: message.member.voice.channel.id,
|
|
86
|
+
textChannel: message.channel.id,
|
|
87
|
+
deaf: true,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const resolve = await client.aqua.resolve({ query, requester: message.member });
|
|
91
|
+
|
|
92
|
+
if (resolve.loadType === 'playlist') {
|
|
93
|
+
await message.channel.send(`Added ${resolve.tracks.length} songs from ${resolve.playlistInfo.name} playlist.`);
|
|
94
|
+
player.queue.add(resolve.tracks);
|
|
95
|
+
if (!player.playing && !player.paused) return player.play();
|
|
96
|
+
|
|
97
|
+
} else if (resolve.loadType === 'search' || resolve.loadType === 'track') {
|
|
98
|
+
const track = resolve.tracks.shift();
|
|
99
|
+
track.info.requester = message.member;
|
|
100
|
+
|
|
101
|
+
player.queue.add(track);
|
|
102
|
+
|
|
103
|
+
await message.channel.send(`Added **${track.info.title}** to the queue.`);
|
|
104
|
+
|
|
105
|
+
if (!player.playing && !player.paused) return player.play();
|
|
106
|
+
|
|
107
|
+
} else {
|
|
108
|
+
return message.channel.send(`There were no results found for your query.`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
client.aqua.on("nodeConnect", (node) => {
|
|
113
|
+
console.log(`Node connected: ${node.name}`);
|
|
114
|
+
});
|
|
115
|
+
client.aqua.on("nodeError", (node, error) => {
|
|
116
|
+
console.log(`Node "${node.name}" encountered an error: ${error.message}.`);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
client.login("Yourtokenhere");
|
|
120
|
+
```
|