lavacord 1.1.8 → 2.0.0

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/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2019-2020 Jacz
189
+ Copyright 2019-2022 Jacz
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,12 +1,9 @@
1
1
  [![Discord](https://discordapp.com/api/guilds/323779330033319941/embed.png)](https://discord.gg/wXrjZmV)
2
- [![npm](https://img.shields.io/npm/v/npm.svg)](https://www.npmjs.com/package/lavacord)
3
- [![npm downloads](https://img.shields.io/npm/dt/lavacord.svg?maxAge=3600)](https://www.npmjs.com/package/lavacord)
4
- [![NPM version](https://badge.fury.io/js/lavacord.svg)](http://badge.fury.io/js/lavacord)
5
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b50839d781c24a94a4e1c17342a147bd)](https://www.codacy.com/app/lavacord/lavacord?utm_source=github.com&utm_medium=referral&utm_content=lavacord/lavacord&utm_campaign=Badge_Grade)
6
- [![Open Source Love](https://badges.frapsoft.com/os/mit/mit.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)
7
- [![dependencies Status](https://david-dm.org/lavacord/lavacord/status.svg)](https://david-dm.org/lavacord/lavacord)
8
- [![devDependencies Status](https://david-dm.org/lavacord/lavacord/dev-status.svg)](https://david-dm.org/lavacord/lavacord?type=dev)
9
- [![NPM](https://nodei.co/npm/lavacord.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/lavacord/)
2
+ [![npm (scoped)](https://img.shields.io/npm/v/lavacord?label=npm%20version)](https://www.npmjs.com/package/lavacord)
3
+ [![npm downloads](https://img.shields.io/npm/dt/lavacord.svg?label=total%20downloads)](https://www.npmjs.com/package/lavacord)
4
+ [![GitHub](https://img.shields.io/github/license/lavacord/lavacord)](https://github.com/lavacord/lavacord/)
5
+ [![Depfu](https://badges.depfu.com/badges/70051aad57dddc0c44a990d26b1f6e23/overview.svg)](https://depfu.com/github/lavacord/Lavacord?project_id=11810)
6
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b50839d781c24a94a4e1c17342a147bd)](https://www.codacy.com/app/lavacord/lavacord)
10
7
 
11
8
  # LavaCord
12
9
  A simple and easy to use lavalink wrapper.
@@ -37,7 +34,7 @@ npm install lavacord/lavacord
37
34
  ## LavaLink configuration
38
35
  Download from [the CI server](https://ci.fredboat.com/viewLog.html?buildId=lastSuccessful&buildTypeId=Lavalink_Build&tab=artifacts&guest=1)
39
36
 
40
- Put an `application.yml` file in your working directory. [Example](https://github.com/Frederikam/Lavalink/blob/master/LavalinkServer/application.yml.example)
37
+ Put an `application.yml` file in your working directory. [Example](https://github.com/freyacodes/Lavalink/blob/master/LavalinkServer/application.yml.example)
41
38
 
42
39
  Run with `java -jar Lavalink.jar`
43
40
 
@@ -45,7 +42,7 @@ Run with `java -jar Lavalink.jar`
45
42
  If you're having a problem with the module contact us in the [**Discord Server**](https://discord.gg/wXrjZmV)
46
43
 
47
44
  # Implementation
48
- Start by creating a new `Manager` passing an array of nodes and an object with `user` the client's user id and `shards` The total number of shards your bot is operating on.
45
+ Start by creating a new `Manager` passing an array of nodes and an object with `user` the client's user id.
49
46
 
50
47
  ```javascript
51
48
  // import the Manager class from lavacord
@@ -59,7 +56,6 @@ const nodes = [
59
56
  // Initilize the Manager with all the data it needs
60
57
  const manager = new Manager(nodes, {
61
58
  user: client.user.id, // Client id
62
- shards: shardCount, // Total number of shards your bot is operating on
63
59
  send: (packet) => {
64
60
  // this needs to send the provided packet to discord using the method from your library. use the @lavacord package for the discord library you use if you don't understand this
65
61
  }
@@ -70,7 +66,7 @@ await manager.connect();
70
66
 
71
67
  // The error event, which you should handle otherwise your application will crash when an error is emitted
72
68
  manager.on("error", (error, node) => {
73
- error // is the error
69
+ error, // is the error
74
70
  node // is the node which the error is from
75
71
  });
76
72
  ```
@@ -78,19 +74,13 @@ manager.on("error", (error, node) => {
78
74
  Resolving tracks using LavaLink REST API
79
75
 
80
76
  ```javascript
81
- const fetch = require("node-fetch");
82
- const { URLSearchParams } = require("url");
77
+ const { Rest } = require("lavacord");
83
78
 
84
79
  async function getSongs(search) {
85
80
  // This gets the best node available, what I mean by that is the idealNodes getter will filter all the connected nodes and then sort them from best to least beast.
86
81
  const node = manager.idealNodes[0];
87
82
 
88
- const params = new URLSearchParams();
89
- params.append("identifier", search);
90
-
91
- return fetch(`http://${node.host}:${node.port}/loadtracks?${params}`, { headers: { Authorization: node.password } })
92
- .then(res => res.json())
93
- .then(data => data.tracks)
83
+ return Rest.load(node, search).then(data => data.tracks)
94
84
  .catch(err => {
95
85
  console.error(err);
96
86
  return null;
@@ -116,7 +106,7 @@ await player.play(track); // Track is a base64 string we get from Lavalink REST
116
106
 
117
107
  player.once("error", error => console.error(error));
118
108
  player.once("end", data => {
119
- if (data.reason === "REPLACED") return; // Ignore REPLACED reason to prevent skip loops
109
+ if (data.type === "TrackEndEvent" && data.reason === "REPLACED") return; // Ignore REPLACED reason to prevent skip loops
120
110
  // Play next song
121
111
  });
122
112
 
@@ -0,0 +1,8 @@
1
+ import { Manager as BaseManager } from "./lib/Manager";
2
+ import type { ManagerOptions, LavalinkNodeOptions } from "./lib/Types";
3
+ import { Client } from "cloudstorm";
4
+ export * from "./index";
5
+ export declare class Manager extends BaseManager {
6
+ readonly client: Client;
7
+ constructor(client: Client, nodes: Array<LavalinkNodeOptions>, options: ManagerOptions);
8
+ }
package/cloudstorm.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Manager = void 0;
18
+ const Manager_1 = require("./lib/Manager");
19
+ __exportStar(require("./index"), exports);
20
+ class Manager extends Manager_1.Manager {
21
+ client;
22
+ constructor(client, nodes, options) {
23
+ super(nodes, options);
24
+ this.client = client;
25
+ if (!this.send) {
26
+ this.send = packet => {
27
+ if (!this.client.options.totalShards)
28
+ return false;
29
+ // eslint-disable-next-line no-bitwise
30
+ const shardID = Number((BigInt(packet.d.guild_id) >> BigInt(22)) % BigInt(this.client.options.totalShards));
31
+ const s = Object.entries(this.client.shardManager.shards).find(e => String(e[0]) === String(shardID))?.[1];
32
+ if (s) {
33
+ s.connector.betterWs.sendMessage(packet);
34
+ return true;
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ };
40
+ }
41
+ client.on("event", packet => {
42
+ if (packet.t === "VOICE_SERVER_UPDATE") {
43
+ this.voiceServerUpdate(packet.d);
44
+ }
45
+ else if (packet.t === "VOICE_STATE_UPDATE") {
46
+ this.voiceStateUpdate(packet.d);
47
+ }
48
+ else if (packet.t === "GUILD_CREATE") {
49
+ for (const state of packet.d.voice_states ?? []) {
50
+ this.voiceStateUpdate({ ...state, guild_id: packet.d.id });
51
+ }
52
+ }
53
+ });
54
+ }
55
+ }
56
+ exports.Manager = Manager;
57
+ //# sourceMappingURL=cloudstorm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudstorm.js","sourceRoot":"","sources":["src/cloudstorm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAKvD,0CAAwB;AAExB,MAAa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C,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAqB,CAAC,CAAC;aACvD;iBAAM,IAAI,MAAM,CAAC,CAAC,KAAK,cAAc,EAAE;gBACpC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,EAAE;oBAC7C,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAG,MAAM,CAAC,CAAgC,CAAC,EAAE,EAAsB,CAAC,CAAC;iBAClH;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAjCD,0BAiCC"}
package/detritus.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Manager as BaseManager } from "./lib/Manager";
2
+ import type { ManagerOptions, LavalinkNodeOptions } from "./lib/Types";
3
+ import type { ClusterClient, ShardClient } from "detritus-client";
4
+ export * from "./index";
5
+ export declare class Manager extends BaseManager {
6
+ readonly client: ClusterClient | ShardClient;
7
+ constructor(client: ClusterClient | ShardClient, nodes: Array<LavalinkNodeOptions>, options: ManagerOptions);
8
+ }
package/detritus.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Manager = void 0;
18
+ const Manager_1 = require("./lib/Manager");
19
+ __exportStar(require("./index"), exports);
20
+ class Manager extends Manager_1.Manager {
21
+ client;
22
+ constructor(client, nodes, options) {
23
+ super(nodes, options);
24
+ this.client = client;
25
+ if (!this.send) {
26
+ this.send = packet => {
27
+ const asCluster = this.client;
28
+ const asShard = this.client;
29
+ if (asShard.guilds) {
30
+ asShard.gateway.send(packet.op, packet.d);
31
+ return true;
32
+ }
33
+ else if (asCluster.shards) {
34
+ const shard = asCluster.shards.find(c => c.guilds.has(packet.d.guild_id));
35
+ if (shard) {
36
+ shard.gateway.send(packet.op, packet.d);
37
+ return true;
38
+ }
39
+ else {
40
+ return false;
41
+ }
42
+ }
43
+ };
44
+ }
45
+ client.on("raw", packet => {
46
+ if (packet.t === "VOICE_SERVER_UPDATE")
47
+ this.voiceServerUpdate(packet.d);
48
+ else if (packet.t === "VOICE_STATE_UPDATE")
49
+ this.voiceStateUpdate(packet.d);
50
+ else if (packet.t === "GUILD_CREATE")
51
+ for (const state of packet.d.voice_states ?? [])
52
+ this.voiceStateUpdate({ ...state, guild_id: packet.d.id });
53
+ });
54
+ }
55
+ }
56
+ exports.Manager = Manager;
57
+ //# sourceMappingURL=detritus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detritus.js","sourceRoot":"","sources":["src/detritus.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAKvD,0CAAwB;AAExB,MAAa,OAAQ,SAAQ,iBAAW;IACD;IAAnC,YAAmC,MAAmC,EAAE,KAAiC,EAAE,OAAuB;QAC9H,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QADS,WAAM,GAAN,MAAM,CAA6B;QAGlE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE;gBACjB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAuB,CAAC;gBAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAqB,CAAC;gBAE3C,IAAI,OAAO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ptions } from "./lib/Types";
3
+ import { Client } from "discord.js";
4
+ export * from "./index";
5
+ export declare class Manager extends BaseManager {
6
+ readonly client: Client;
7
+ constructor(client: Client, nodes: Array<LavalinkNodeOptions>, options?: ManagerOptions);
8
+ }
package/discord.js.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Manager = void 0;
18
+ const Manager_1 = require("./lib/Manager");
19
+ const discord_js_1 = require("discord.js");
20
+ __exportStar(require("./index"), exports);
21
+ class Manager extends Manager_1.Manager {
22
+ client;
23
+ constructor(client, nodes, options) {
24
+ if (!options)
25
+ options = {};
26
+ if (!options.user)
27
+ options.user = client.user?.id;
28
+ super(nodes, options);
29
+ this.client = client;
30
+ if (!this.send) {
31
+ this.send = packet => {
32
+ const guild = this.client.guilds.cache.get(packet.d.guild_id);
33
+ if (guild) {
34
+ guild.shard.send(packet);
35
+ return true;
36
+ }
37
+ else {
38
+ return false;
39
+ }
40
+ };
41
+ }
42
+ client.ws
43
+ .on(discord_js_1.GatewayDispatchEvents.VoiceServerUpdate, this.voiceServerUpdate.bind(this))
44
+ .on(discord_js_1.GatewayDispatchEvents.VoiceStateUpdate, this.voiceStateUpdate.bind(this))
45
+ .on(discord_js_1.GatewayDispatchEvents.GuildCreate, data => {
46
+ for (const state of data.voice_states ?? [])
47
+ this.voiceStateUpdate({ ...state, guild_id: data.id });
48
+ });
49
+ }
50
+ }
51
+ exports.Manager = Manager;
52
+ //# sourceMappingURL=discord.js.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord.js.js","sourceRoot":"","sources":["src/discord.js.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAGvD,2CAA2D;AAE3D,0CAAwB;AAExB,MAAa,OAAQ,SAAQ,iBAAW;IACD;IAAnC,YAAmC,MAAc,EAAE,KAAiC,EAAE,OAAwB;QAC1G,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAClD,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAHS,WAAM,GAAN,MAAM,CAAQ;QAK7C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gBAC9D,IAAI,KAAK,EAAE;oBACP,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACzB,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,CAAC;SACL;QAED,MAAM,CAAC,EAAE;aACJ,EAAE,CAAC,kCAAqB,CAAC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9E,EAAE,CAAC,kCAAqB,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC5E,EAAE,CAAC,kCAAqB,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE;YAC1C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,IAAI,EAAE;gBAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACxG,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AAzBD,0BAyBC"}
package/eris.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Manager as BaseManager } from "./lib/Manager";
2
+ import type { ManagerOptions, LavalinkNodeOptions } from "./lib/Types";
3
+ import type { Client } from "eris";
4
+ export * from "./index";
5
+ export declare class Manager extends BaseManager {
6
+ readonly client: Client;
7
+ constructor(client: Client, nodes: Array<LavalinkNodeOptions>, options?: ManagerOptions);
8
+ }
package/eris.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Manager = void 0;
18
+ const Manager_1 = require("./lib/Manager");
19
+ __exportStar(require("./index"), exports);
20
+ class Manager extends Manager_1.Manager {
21
+ client;
22
+ constructor(client, nodes, options) {
23
+ if (!options)
24
+ options = {};
25
+ if (!options.user)
26
+ options.user = client.user?.id;
27
+ super(nodes, options);
28
+ this.client = client;
29
+ if (!this.send) {
30
+ this.send = packet => {
31
+ const guild = this.client.guilds.get(packet.d.guild_id);
32
+ if (guild) {
33
+ guild.shard.sendWS(packet.op, packet.d);
34
+ return true;
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ };
40
+ }
41
+ client.on("rawWS", (packet) => {
42
+ if (packet.t === "VOICE_SERVER_UPDATE")
43
+ this.voiceServerUpdate(packet.d);
44
+ else if (packet.t === "VOICE_STATE_UPDATE")
45
+ this.voiceStateUpdate(packet.d);
46
+ else if (packet.t === "GUILD_CREATE")
47
+ for (const state of packet.d.voice_states ?? [])
48
+ this.voiceStateUpdate({ ...state, guild_id: packet.d.id });
49
+ });
50
+ }
51
+ }
52
+ exports.Manager = Manager;
53
+ //# sourceMappingURL=eris.js.map
package/eris.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eris.js","sourceRoot":"","sources":["src/eris.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAKvD,0CAAwB;AAExB,MAAa,OAAQ,SAAQ,iBAAW;IACD;IAAnC,YAAmC,MAAc,EAAE,KAAiC,EAAE,OAAwB;QAC1G,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAClD,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAHS,WAAM,GAAN,MAAM,CAAQ;QAK7C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gBACxD,IAAI,KAAK,EAAE;oBACP,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;oBACxC,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,CAAC;SACL;QAED,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,MAAqB,EAAE,EAAE;YACzC,IAAI,MAAM,CAAC,CAAC,KAAK,qBAAqB;gBAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBACpE,IAAI,MAAM,CAAC,CAAC,KAAK,oBAAoB;gBAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBACvE,IAAI,MAAM,CAAC,CAAC,KAAK,cAAc;gBAAE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE;oBAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtJ,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAxBD,0BAwBC"}
package/oceanic.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Manager as BaseManager } from "./lib/Manager";
2
+ import type { ManagerOptions, LavalinkNodeOptions } from "./lib/Types";
3
+ import type { Client } from "oceanic.js";
4
+ export * from "./index";
5
+ export declare class Manager extends BaseManager {
6
+ readonly client: Client;
7
+ constructor(client: Client, nodes: Array<LavalinkNodeOptions>, options?: ManagerOptions);
8
+ }
package/oceanic.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Manager = void 0;
18
+ const Manager_1 = require("./lib/Manager");
19
+ __exportStar(require("./index"), exports);
20
+ class Manager extends Manager_1.Manager {
21
+ client;
22
+ constructor(client, nodes, options) {
23
+ if (!options)
24
+ options = {};
25
+ if (!options.user)
26
+ options.user = client.user?.id;
27
+ super(nodes, options);
28
+ this.client = client;
29
+ if (!this.send) {
30
+ this.send = packet => {
31
+ const guild = this.client.guilds.get(packet.d.guild_id);
32
+ if (guild) {
33
+ guild.shard.send(packet.op, packet.d);
34
+ return true;
35
+ }
36
+ else {
37
+ return false;
38
+ }
39
+ };
40
+ }
41
+ client.on("packet", packet => {
42
+ if (packet.t === "VOICE_SERVER_UPDATE") {
43
+ this.voiceServerUpdate(packet.d);
44
+ }
45
+ else if (packet.t === "VOICE_STATE_UPDATE") {
46
+ this.voiceStateUpdate(packet.d);
47
+ }
48
+ else if (packet.t === "GUILD_CREATE") {
49
+ for (const state of packet.d.voice_states ?? []) {
50
+ this.voiceStateUpdate({ ...state, guild_id: packet.d.id });
51
+ }
52
+ }
53
+ });
54
+ }
55
+ }
56
+ exports.Manager = Manager;
57
+ //# sourceMappingURL=oceanic.js.map
package/oceanic.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oceanic.js","sourceRoot":"","sources":["src/oceanic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAuD;AAIvD,0CAAwB;AAExB,MAAa,OAAQ,SAAQ,iBAAW;IACD;IAAnC,YAAmC,MAAc,EAAE,KAAiC,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AClF;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA9BD,0BA8BC"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "lavacord",
3
- "version": "1.1.8",
3
+ "version": "2.0.0",
4
4
  "description": "A simple by design lavalink wrapper made for any discord library.",
5
- "main": "dist/index",
6
- "types": "dist/index.d.ts",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
7
  "scripts": {
8
8
  "prepublishOnly": "yarn compile",
9
9
  "lint": "eslint --fix --ext ts src",
@@ -35,23 +35,33 @@
35
35
  },
36
36
  "homepage": "https://github.com/MrJacz/lavacord#readme",
37
37
  "dependencies": {
38
- "node-fetch": "^2.6.0",
39
- "ws": "^7.3.0"
38
+ "lavalink-types": "^2.0.2",
39
+ "undici": "^5.22.1",
40
+ "ws": "^8.13.0"
40
41
  },
41
42
  "devDependencies": {
42
- "@types/node": "^14.0.1",
43
- "@types/node-fetch": "^2.5.7",
44
- "@types/ws": "^7.2.4",
45
- "@typescript-eslint/eslint-plugin": "^2.33.0",
46
- "@typescript-eslint/parser": "^2.33.0",
47
- "eslint": "^7.0.0",
43
+ "@types/node": "^20.3.3",
44
+ "@types/ws": "^8.5.5",
45
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
46
+ "@typescript-eslint/parser": "^5.61.0",
47
+ "eslint": "^8.44.0",
48
48
  "eslint-plugin-node": "^11.1.0",
49
- "eslint-plugin-promise": "^4.2.1",
50
- "typedoc": "^0.17.7",
51
- "typescript": "^3.9.2"
49
+ "eslint-plugin-promise": "^6.1.1",
50
+ "typedoc": "^0.24.8",
51
+ "typescript": "^5.1.6"
52
+ },
53
+ "optionalDependencies": {
54
+ "discord.js": "14.x",
55
+ "eris": "0.17.x",
56
+ "detritus-client": "0.16.x",
57
+ "cloudstorm": "0.8.x",
58
+ "oceanic.js": "1.7.1"
52
59
  },
53
60
  "files": [
54
- "dist",
61
+ "/*.js",
62
+ "/*.d.ts",
63
+ "/*.js.map",
64
+ "lib",
55
65
  "LICENCE"
56
66
  ],
57
67
  "engines": {
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from "./lib/LavalinkNode";
2
- export * from "./lib/Player";
3
- export * from "./lib/Manager";
4
- export * from "./lib/Rest";
5
- export * from "./lib/Types";
package/dist/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./lib/LavalinkNode"), exports);
14
- __exportStar(require("./lib/Player"), exports);
15
- __exportStar(require("./lib/Manager"), exports);
16
- __exportStar(require("./lib/Rest"), exports);
17
- __exportStar(require("./lib/Types"), exports);
18
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmC;AACnC,+CAA6B;AAC7B,gDAA8B;AAC9B,6CAA2B;AAC3B,8CAA4B"}
@@ -1,30 +0,0 @@
1
- import WebSocket from "ws";
2
- import { Manager } from "./Manager";
3
- import { LavalinkNodeOptions, LavalinkStats } from "./Types";
4
- export declare class LavalinkNode {
5
- manager: Manager;
6
- id: string;
7
- host: string;
8
- port: number | string;
9
- reconnectInterval: number;
10
- password: string;
11
- ws: WebSocket | null;
12
- stats: LavalinkStats;
13
- resumeKey?: string;
14
- resumeTimeout: number;
15
- private _reconnect?;
16
- private _queue;
17
- constructor(manager: Manager, options: LavalinkNodeOptions);
18
- connect(): Promise<WebSocket | boolean>;
19
- send(msg: object): Promise<boolean>;
20
- configureResuming(key: string, timeout?: number): Promise<boolean>;
21
- destroy(): boolean;
22
- get connected(): boolean;
23
- private onOpen;
24
- private onMessage;
25
- private onError;
26
- private onClose;
27
- private reconnect;
28
- private _send;
29
- private _queueFlush;
30
- }