hoshimi 0.2.5 → 0.3.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/dist/index.mjs CHANGED
@@ -250,6 +250,11 @@ var HttpMethods = /* @__PURE__ */ ((HttpMethods2) => {
250
250
  HttpMethods2["Head"] = "HEAD";
251
251
  return HttpMethods2;
252
252
  })(HttpMethods || {});
253
+ var RestPathType = /* @__PURE__ */ ((RestPathType2) => {
254
+ RestPathType2["Raw"] = "/";
255
+ RestPathType2["V4"] = "/v4";
256
+ return RestPathType2;
257
+ })(RestPathType || {});
253
258
  var HttpStatusCodes = /* @__PURE__ */ ((HttpStatusCodes2) => {
254
259
  HttpStatusCodes2[HttpStatusCodes2["OK"] = 200] = "OK";
255
260
  HttpStatusCodes2[HttpStatusCodes2["Created"] = 201] = "Created";
@@ -459,12 +464,12 @@ var UnresolvedTrack = class {
459
464
  // package.json
460
465
  var package_default = {
461
466
  name: "hoshimi",
462
- version: "0.2.5",
467
+ version: "0.3.1",
463
468
  description: "A lavalink@v4 client easy to use, up-to-date and all ears.",
464
469
  main: "./dist/index.js",
465
470
  module: "./dist/index.mjs",
466
471
  types: "./dist/index.d.ts",
467
- packageManager: "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd",
472
+ packageManager: "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a",
468
473
  files: [
469
474
  "dist"
470
475
  ],
@@ -500,13 +505,13 @@ var package_default = {
500
505
  author: "Ganyu Studios",
501
506
  license: "MIT",
502
507
  devDependencies: {
503
- "@biomejs/biome": "^2.3.2",
504
- "@types/node": "^24.9.2",
508
+ "@biomejs/biome": "^2.3.8",
509
+ "@types/node": "^24.10.1",
505
510
  "@types/ws": "^8.18.1",
506
511
  husky: "^9.1.7",
507
- "lint-staged": "^16.2.6",
508
- tsup: "^8.5.0",
509
- tsx: "^4.20.6",
512
+ "lint-staged": "^16.2.7",
513
+ tsup: "^8.5.1",
514
+ tsx: "^4.21.0",
510
515
  typescript: "^5.9.3"
511
516
  },
512
517
  dependencies: {
@@ -572,7 +577,7 @@ var ValidSources = new Map(
572
577
  ["pornhub" /* PornHub */]: "phsearch" /* PornHub */
573
578
  })
574
579
  );
575
- var AudioOutputData = {
580
+ var AudioOutputData = Object.freeze({
576
581
  ["mono" /* Mono */]: {
577
582
  leftToLeft: 0.5,
578
583
  leftToRight: 0.5,
@@ -597,7 +602,7 @@ var AudioOutputData = {
597
602
  rightToLeft: 0,
598
603
  rightToRight: 1
599
604
  }
600
- };
605
+ });
601
606
  var DefaultFilterPreset = Object.freeze({
602
607
  Karaoke: { level: 1, monoLevel: 1, filterBand: 220, filterWidth: 100 },
603
608
  Vaporwave: { speed: 0.8500000238418579, pitch: 0.800000011920929, rate: 1 },
@@ -615,6 +620,8 @@ var DefaultFilterPreset = Object.freeze({
615
620
  });
616
621
  var DefaultPlayerFilters = Object.freeze({
617
622
  volume: 1,
623
+ equalizer: [],
624
+ channelMix: AudioOutputData.mono,
618
625
  lowPass: {
619
626
  smoothing: 0
620
627
  },
@@ -669,7 +676,6 @@ var DefaultPlayerFilters = Object.freeze({
669
676
  maxAmplitude: 0
670
677
  }
671
678
  },
672
- equalizer: [],
673
679
  distortion: {
674
680
  cosOffset: 0,
675
681
  sinOffset: 0,
@@ -679,8 +685,7 @@ var DefaultPlayerFilters = Object.freeze({
679
685
  cosScale: 1,
680
686
  sinScale: 1,
681
687
  tanScale: 1
682
- },
683
- channelMix: AudioOutputData.mono
688
+ }
684
689
  });
685
690
 
686
691
  // src/util/functions/utils.ts
@@ -787,6 +792,24 @@ function isUnresolvedTrack(track) {
787
792
  function isValid(value) {
788
793
  return typeof value !== "undefined" && value !== null;
789
794
  }
795
+ function stringify(value, space) {
796
+ const seen = /* @__PURE__ */ new WeakSet();
797
+ return JSON.stringify(
798
+ value,
799
+ (_, value2) => {
800
+ if (typeof value2 === "function") return void 0;
801
+ if (typeof value2 === "symbol") return void 0;
802
+ if (typeof value2 === "bigint") return value2.toString();
803
+ if (typeof value2 === "object" && value2 !== null) {
804
+ if (seen.has(value2)) return void 0;
805
+ seen.add(value2);
806
+ return value2;
807
+ }
808
+ return value2;
809
+ },
810
+ space
811
+ );
812
+ }
790
813
  function isNode(options) {
791
814
  return typeof options.host === "string" && typeof options.port === "number" && typeof options.password === "string" && (typeof options.id === "string" || typeof options.id === "undefined") && (typeof options.secure === "boolean" || typeof options.secure === "undefined") && (typeof options.sessionId === "string" || typeof options.sessionId === "undefined") && (typeof options.retryAmount === "number" || typeof options.retryAmount === "undefined") && (typeof options.retryDelay === "number" || typeof options.retryDelay === "undefined");
792
815
  }
@@ -1020,7 +1043,7 @@ var NodeManager = class {
1020
1043
  /**
1021
1044
  *
1022
1045
  * Delete the node.
1023
- * @param {string} id The id of the node to delete.
1046
+ * @param {NodeIdentifier} node The node or node id to delete.
1024
1047
  * @returns {boolean} If the node was deleted.
1025
1048
  * @example
1026
1049
  * ```ts
@@ -1028,23 +1051,122 @@ var NodeManager = class {
1028
1051
  * if (node) manager.nodeManager.delete(node.id); // true if the node was deleted
1029
1052
  * ```
1030
1053
  */
1031
- delete(id) {
1054
+ delete(node) {
1055
+ const id = typeof node === "string" ? node : node.id;
1032
1056
  return this.nodes.delete(id);
1033
1057
  }
1034
1058
  /**
1035
1059
  *
1036
1060
  * Get the node by id.
1037
- * @param {string} id The id of the node.
1061
+ * @param {NodeIdentifier} node The node or node id to get.
1038
1062
  * @returns {NodeStructure | undefined} The node or undefined if not found.
1039
1063
  * @example
1040
1064
  * ```ts
1041
1065
  * const node = manager.nodeManager.get("node1");
1042
- * if (node) console.log(node.id); // node1
1066
+ * if (node) {
1067
+ * console.log(node.id); // node1
1068
+ * } else {
1069
+ * console.log("Node not found");
1070
+ * }
1043
1071
  * ```
1044
1072
  */
1045
- get(id) {
1073
+ get(node) {
1074
+ const id = typeof node === "string" ? node : node.id;
1046
1075
  return this.nodes.get(id);
1047
1076
  }
1077
+ /**
1078
+ *
1079
+ * Create a new node.
1080
+ * @param {NodeOptions} options The options for the node.
1081
+ * @returns {NodeStructure} The created node.
1082
+ * @example
1083
+ * ```ts
1084
+ * const node = manager.nodeManager.create({
1085
+ * host: "localhost",
1086
+ * port: 2333,
1087
+ * password: "password",
1088
+ * secure: false,
1089
+ * });
1090
+ *
1091
+ * console.log(node.id); // localhost:2333
1092
+ */
1093
+ create(options) {
1094
+ options.id ??= `${options.host}:${options.port}`;
1095
+ const oldNode = this.nodes.get(options.id);
1096
+ if (oldNode) return oldNode;
1097
+ const node = Structures.Node(this, options);
1098
+ this.nodes.set(node.id, node);
1099
+ this.manager.emit("nodeCreate" /* NodeCreate */, node);
1100
+ return node;
1101
+ }
1102
+ /**
1103
+ *
1104
+ * Destroy a node.
1105
+ * @param {NodeIdentifier} node The node or node id to destroy.
1106
+ * @returns {void}
1107
+ * @example
1108
+ * ```ts
1109
+ * const node = manager.nodeManager.get("node1");
1110
+ * if (node) node.destroy();
1111
+ * ```
1112
+ */
1113
+ destroy(node) {
1114
+ const id = typeof node === "string" ? node : node.id;
1115
+ const target = this.nodes.get(id);
1116
+ if (!target) return;
1117
+ target.destroy();
1118
+ }
1119
+ /**
1120
+ *
1121
+ * Reconnect a node.
1122
+ * @param {NodeIdentifier} node The node or node id to reconnect.
1123
+ * @returns {void}
1124
+ * @example
1125
+ * ```ts
1126
+ * const node = manager.nodeManager.get("node1");
1127
+ * if (node) node.reconnect();
1128
+ * ```
1129
+ */
1130
+ reconnect(node) {
1131
+ const id = typeof node === "string" ? node : node.id;
1132
+ const target = this.nodes.get(id);
1133
+ if (!target) return;
1134
+ target.reconnect();
1135
+ }
1136
+ /**
1137
+ *
1138
+ * Disconnect a node.
1139
+ * @param {NodeIdentifier} node The node or node id to disconnect.
1140
+ * @returns {void}
1141
+ * @example
1142
+ * ```ts
1143
+ * const node = manager.nodeManager.get("node1");
1144
+ * if (node) node.disconnect();
1145
+ * ```
1146
+ */
1147
+ disconnect(node) {
1148
+ const id = typeof node === "string" ? node : node.id;
1149
+ const target = this.nodes.get(id);
1150
+ if (!target) return;
1151
+ target.disconnect();
1152
+ }
1153
+ /**
1154
+ *
1155
+ * Connect a node.
1156
+ * @param {NodeIdentifier} node The node or node id to connect.
1157
+ * @returns {void}
1158
+ * @example
1159
+ * ```ts
1160
+ * const node = manager.nodeManager.get("node1");
1161
+ * if (node) node.connect();
1162
+ * ```
1163
+ */
1164
+ connect(node) {
1165
+ const id = typeof node === "string" ? node : node.id;
1166
+ const target = this.nodes.get(id);
1167
+ if (!target) return;
1168
+ target.connect();
1169
+ }
1048
1170
  /**
1049
1171
  *
1050
1172
  * Get the least used node.
@@ -1087,31 +1209,6 @@ var NodeManager = class {
1087
1209
  });
1088
1210
  }
1089
1211
  }
1090
- /**
1091
- *
1092
- * Create a new node.
1093
- * @param {NodeOptions} options The options for the node.
1094
- * @returns {NodeStructure} The created node.
1095
- * @example
1096
- * ```ts
1097
- * const node = manager.nodeManager.create({
1098
- * host: "localhost",
1099
- * port: 2333,
1100
- * password: "password",
1101
- * secure: false,
1102
- * });
1103
- *
1104
- * console.log(node.id); // localhost:2333
1105
- */
1106
- create(options) {
1107
- options.id ??= `${options.host}:${options.port}`;
1108
- const oldNode = this.nodes.get(options.id);
1109
- if (oldNode) return oldNode;
1110
- const node = Structures.Node(this, options);
1111
- this.nodes.set(node.id, node);
1112
- this.manager.emit("nodeCreate" /* NodeCreate */, node);
1113
- return node;
1114
- }
1115
1212
  /**
1116
1213
  *
1117
1214
  * Reconnect the nodes.
@@ -1119,10 +1216,10 @@ var NodeManager = class {
1119
1216
  * @example
1120
1217
  * ```ts
1121
1218
  * const node = manager.nodeManager.get("node1");
1122
- * if (node) node.reconnect();
1219
+ * if (node) node.reconnectAll();
1123
1220
  * ```
1124
1221
  */
1125
- reconnect() {
1222
+ reconnectAll() {
1126
1223
  if (!this.nodes.size) return;
1127
1224
  for (const node of this.nodes.filter((node2) => node2.state !== 2 /* Connected */)) {
1128
1225
  node.reconnect();
@@ -1134,10 +1231,10 @@ var NodeManager = class {
1134
1231
  * @example
1135
1232
  * ```ts
1136
1233
  * const node = manager.nodeManager.get("node1");
1137
- * if (node) node.disconnect();
1234
+ * if (node) node.disconnectAll();
1138
1235
  * ```
1139
1236
  */
1140
- disconnect() {
1237
+ disconnectAll() {
1141
1238
  if (!this.nodes.size) return;
1142
1239
  for (const node of this.nodes.filter((node2) => node2.state !== 3 /* Disconnected */)) {
1143
1240
  node.disconnect();
@@ -1152,7 +1249,7 @@ var NodeManager = class {
1152
1249
  * if (node) node.connect();
1153
1250
  * ```
1154
1251
  */
1155
- connect() {
1252
+ connectAll() {
1156
1253
  if (!this.nodes.size) return;
1157
1254
  for (const node of this.nodes.filter((node2) => node2.state !== 2 /* Connected */)) {
1158
1255
  node.connect();
@@ -1167,7 +1264,7 @@ var NodeManager = class {
1167
1264
  * if (node) node.destroy();
1168
1265
  * ```
1169
1266
  */
1170
- destroy() {
1267
+ destroyAll() {
1171
1268
  if (!this.nodes.size) return;
1172
1269
  for (const node of this.nodes.values()) {
1173
1270
  node.destroy();
@@ -1333,7 +1430,7 @@ async function playerUpdate(payload) {
1333
1430
  this.nodeManager.manager.emit(
1334
1431
  "debug" /* Debug */,
1335
1432
  2 /* Node */,
1336
- `[Player] -> [Update] Player updated: ${player.guildId} | Payload: ${JSON.stringify(payload)}`
1433
+ `[Player] -> [Update] Player updated: ${player.guildId} | Payload: ${stringify(payload)}`
1337
1434
  );
1338
1435
  }
1339
1436
  async function lyricsFound(track, payload) {
@@ -1341,7 +1438,7 @@ async function lyricsFound(track, payload) {
1341
1438
  this.manager.emit(
1342
1439
  "debug" /* Debug */,
1343
1440
  3 /* Player */,
1344
- `[Player] -> [Lyrics] The lyrics have been found: ${this.guildId} | Payload: ${JSON.stringify(payload)}`
1441
+ `[Player] -> [Lyrics] The lyrics have been found: ${this.guildId} | Payload: ${stringify(payload)}`
1345
1442
  );
1346
1443
  }
1347
1444
  async function lyricsLine(track, payload) {
@@ -1349,7 +1446,7 @@ async function lyricsLine(track, payload) {
1349
1446
  this.manager.emit(
1350
1447
  "debug" /* Debug */,
1351
1448
  3 /* Player */,
1352
- `[Player] -> [Lyrics] The lyrics line has been found: ${this.guildId} | Payload: ${JSON.stringify(payload)}`
1449
+ `[Player] -> [Lyrics] The lyrics line has been found: ${this.guildId} | Payload: ${stringify(payload)}`
1353
1450
  );
1354
1451
  }
1355
1452
  async function lyricsNotFound(track, payload) {
@@ -1357,7 +1454,7 @@ async function lyricsNotFound(track, payload) {
1357
1454
  this.manager.emit(
1358
1455
  "debug" /* Debug */,
1359
1456
  3 /* Player */,
1360
- `[Player] -> [Lyrics] The lyrics were not found: ${this.guildId} | Payload: ${JSON.stringify(payload)}`
1457
+ `[Player] -> [Lyrics] The lyrics were not found: ${this.guildId} | Payload: ${stringify(payload)}`
1361
1458
  );
1362
1459
  }
1363
1460
  async function socketClosed(payload) {
@@ -1365,7 +1462,7 @@ async function socketClosed(payload) {
1365
1462
  this.manager.emit(
1366
1463
  "debug" /* Debug */,
1367
1464
  3 /* Player */,
1368
- `[Player] -> [Socket] The socket has closed: ${this.guildId} | Payload: ${JSON.stringify(payload)}`
1465
+ `[Player] -> [Socket] The socket has closed: ${this.guildId} | Payload: ${stringify(payload)}`
1369
1466
  );
1370
1467
  }
1371
1468
 
@@ -1515,11 +1612,7 @@ async function onMessage(message) {
1515
1612
  break;
1516
1613
  }
1517
1614
  }
1518
- this.nodeManager.manager.emit(
1519
- "debug" /* Debug */,
1520
- 2 /* Node */,
1521
- `[Socket] -> [${this.id}]: Received payload: ${JSON.stringify(payload)}`
1522
- );
1615
+ this.nodeManager.manager.emit("debug" /* Debug */, 2 /* Node */, `[Socket] -> [${this.id}]: Received payload: ${stringify(payload)}`);
1523
1616
  } catch (error) {
1524
1617
  this.nodeManager.manager.emit("nodeError" /* NodeError */, this, error);
1525
1618
  }
@@ -1654,7 +1747,7 @@ var Node = class {
1654
1747
  const raw = await this.rest.request({
1655
1748
  endpoint: "/decodetracks",
1656
1749
  method: "POST" /* Post */,
1657
- body: JSON.stringify(tracks)
1750
+ body: stringify(tracks)
1658
1751
  }) ?? [];
1659
1752
  return raw.map((track) => new Track(track, requester));
1660
1753
  }
@@ -1751,6 +1844,7 @@ var Node = class {
1751
1844
  * ```
1752
1845
  */
1753
1846
  connect() {
1847
+ if (this.state === 2 /* Connected */ || this.state === 1 /* Connecting */) return;
1754
1848
  if (!this.nodeManager.manager.options.client)
1755
1849
  throw new NodeError({
1756
1850
  message: "No valid client data provided.",
@@ -1785,7 +1879,7 @@ var Node = class {
1785
1879
  this.nodeManager.manager.emit(
1786
1880
  "debug" /* Debug */,
1787
1881
  2 /* Node */,
1788
- `[Socket] -> [${this.id}]: Connecting to ${this.address} | State: ${this.state} | Session: ${this.sessionId} | Resumed: ${this.session.resuming} | Penalties: ${this.penalties} | Reconnects: ${this.retryAmount} | Headers: ${JSON.stringify(headers)}`
1882
+ `[Socket] -> [${this.id}]: Connecting to ${this.address} | State: ${this.state} | Session: ${this.sessionId} | Resumed: ${this.session.resuming} | Penalties: ${this.penalties} | Reconnects: ${this.retryAmount} | Headers: ${stringify(headers)}`
1789
1883
  );
1790
1884
  }
1791
1885
  /**
@@ -1926,6 +2020,7 @@ var Node = class {
1926
2020
  * ```
1927
2021
  */
1928
2022
  reconnect() {
2023
+ if (this.state === 3 /* Disconnected */ || this.state === 6 /* Destroyed */) return;
1929
2024
  this.state = 7 /* Idle */;
1930
2025
  this.nodeManager.manager.emit("nodeReconnecting" /* NodeReconnecting */, this, this.retryAmount, this.retryDelay);
1931
2026
  this.reconnectTimeout = setTimeout(() => {
@@ -2062,7 +2157,7 @@ var Rest = class {
2062
2157
  */
2063
2158
  constructor(node) {
2064
2159
  const manager = node.nodeManager.manager;
2065
- this.url = `${node.options.secure ? "https" : "http"}://${node.options.host}:${node.options.port}/${this.version}`;
2160
+ this.url = `${node.options.secure ? "https" : "http"}://${node.options.host}:${node.options.port}`;
2066
2161
  this.restTimeout = node.options.restTimeout ?? manager.options.restOptions.resumeTimeout ?? 1e4;
2067
2162
  this.userAgent = manager.options.nodeOptions.userAgent ?? HoshimiAgent;
2068
2163
  this.node = node;
@@ -2095,7 +2190,9 @@ var Rest = class {
2095
2190
  Authorization: this.node.options.password
2096
2191
  };
2097
2192
  options.method ??= "GET" /* Get */;
2098
- const url = new URL(`${this.url}${options.endpoint}`);
2193
+ options.pathType ??= "/v4" /* V4 */;
2194
+ const path = `${options.pathType}${options.endpoint}`.replace(/\/+/g, "/");
2195
+ const url = new URL(`${this.url}${path}`);
2099
2196
  if (options.params) {
2100
2197
  for (const [key, value] of Object.entries(options.params)) {
2101
2198
  url.searchParams.append(key, value);
@@ -2111,12 +2208,12 @@ var Rest = class {
2111
2208
  };
2112
2209
  if (!["GET" /* Get */, "HEAD" /* Head */].includes(options.method) && options.body) {
2113
2210
  if (typeof options.body === "string") fetchOptions.body = options.body;
2114
- else fetchOptions.body = JSON.stringify(options.body);
2211
+ else fetchOptions.body = stringify(options.body);
2115
2212
  }
2116
2213
  this.node.nodeManager.manager.emit(
2117
2214
  "debug" /* Debug */,
2118
2215
  4 /* Rest */,
2119
- `[Rest] -> [${this.node.id} : ${options.method}]: Url: ${this.restUrl} | Endpoint: ${options.endpoint} | Params: ${url.search} | Body: ${options.body ? JSON.stringify(options.body) : "None"} | Headers: ${JSON.stringify(headers)}`
2216
+ `[Rest] -> [${this.node.id} : ${options.method}]: Url: ${this.restUrl} | Endpoint: ${options.endpoint} | Params: ${url.search} | Body: ${options.body ? stringify(options.body) : "None"} | Headers: ${stringify(headers)}`
2120
2217
  );
2121
2218
  const response = await fetch(url.toString(), fetchOptions).finally(() => clearTimeout(timeout));
2122
2219
  if (!response.ok) {
@@ -2158,7 +2255,7 @@ var Rest = class {
2158
2255
  this.node.nodeManager.manager.emit(
2159
2256
  "debug" /* Debug */,
2160
2257
  4 /* Rest */,
2161
- `[Rest] -> [${this.node.id}]: Updated player data for guild: ${data.guildId} | Payload: ${JSON.stringify(data)}`
2258
+ `[Rest] -> [${this.node.id}]: Updated player data for guild: ${data.guildId} | Payload: ${stringify(data)}`
2162
2259
  );
2163
2260
  validatePlayerData.call(this.node, data);
2164
2261
  return this.request({
@@ -2263,7 +2360,7 @@ var DSPXPluginFilter = class {
2263
2360
  *
2264
2361
  * Set the low-pass filter with the given settings.
2265
2362
  * @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXLowPass] The settings for the low-pass filter.
2266
- * @returns {Promise<boolean>} Whether the filter is now active.
2363
+ * @returns {Promise<this>} The instance of the filter manager.
2267
2364
  */
2268
2365
  async setLowPass(settings = DefaultFilterPreset.DSPXLowPass) {
2269
2366
  validateNodePlugins(this.manager.player.node, ["lavadspx-plugin" /* LavaDspx */]);
@@ -2279,13 +2376,13 @@ var DSPXPluginFilter = class {
2279
2376
  }
2280
2377
  this.manager.filters.lavalinkLavaDspxPlugin.lowPass = !this.manager.filters.lavalinkLavaDspxPlugin.lowPass;
2281
2378
  await this.manager.apply();
2282
- return this.manager.filters.lavalinkLavaDspxPlugin.lowPass;
2379
+ return this;
2283
2380
  }
2284
2381
  /**
2285
2382
  *
2286
2383
  * Set the high-pass filter with the given settings.
2287
2384
  * @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXHighPass] The settings for the high-pass filter.
2288
- * @returns {Promise<boolean>} Whether the filter is now active.
2385
+ * @returns {Promise<this>} The instance of the filter manager.
2289
2386
  */
2290
2387
  async setHighPass(settings = DefaultFilterPreset.DSPXHighPass) {
2291
2388
  validateNodePlugins(this.manager.player.node, ["lavadspx-plugin" /* LavaDspx */]);
@@ -2301,13 +2398,13 @@ var DSPXPluginFilter = class {
2301
2398
  }
2302
2399
  this.manager.filters.lavalinkLavaDspxPlugin.highPass = !this.manager.filters.lavalinkLavaDspxPlugin.highPass;
2303
2400
  await this.manager.apply();
2304
- return this.manager.filters.lavalinkLavaDspxPlugin.highPass;
2401
+ return this;
2305
2402
  }
2306
2403
  /**
2307
2404
  *
2308
2405
  * Set the normalization filter with the given settings.
2309
2406
  * @param {NormalizationSettings} [settings=DefaultFilter.DSPXNormalization] The settings for the normalization filter.
2310
- * @returns {Promise<boolean>} Whether the filter is now active.
2407
+ * @returns {Promise<this>} The instance of the filter manager.
2311
2408
  */
2312
2409
  async setNormalization(settings = DefaultFilterPreset.DSPXNormalization) {
2313
2410
  validateNodePlugins(this.manager.player.node, ["lavadspx-plugin" /* LavaDspx */]);
@@ -2323,13 +2420,13 @@ var DSPXPluginFilter = class {
2323
2420
  }
2324
2421
  this.manager.filters.lavalinkLavaDspxPlugin.normalization = !this.manager.filters.lavalinkLavaDspxPlugin.normalization;
2325
2422
  await this.manager.apply();
2326
- return this.manager.filters.lavalinkLavaDspxPlugin.normalization;
2423
+ return this;
2327
2424
  }
2328
2425
  /**
2329
2426
  *
2330
2427
  * Set the echo filter with the given settings.
2331
2428
  * @param {EchoSettings} [settings=DefaultFilter.DSPXEcho] The settings for the echo filter.
2332
- * @returns {Promise<boolean>} Whether the filter is now active.
2429
+ * @returns {Promise<this>} The instance of the filter manager.
2333
2430
  */
2334
2431
  async setEcho(settings = DefaultFilterPreset.DSPXEcho) {
2335
2432
  validateNodePlugins(this.manager.player.node, ["lavadspx-plugin" /* LavaDspx */]);
@@ -2345,7 +2442,7 @@ var DSPXPluginFilter = class {
2345
2442
  }
2346
2443
  this.manager.filters.lavalinkLavaDspxPlugin.echo = !this.manager.filters.lavalinkLavaDspxPlugin.echo;
2347
2444
  await this.manager.apply();
2348
- return this.manager.filters.lavalinkLavaDspxPlugin.echo;
2445
+ return this;
2349
2446
  }
2350
2447
  };
2351
2448
 
@@ -2369,7 +2466,7 @@ var LavalinkPluginFilter = class {
2369
2466
  *
2370
2467
  * Set the echo filter with the given settings.
2371
2468
  * @param {Omit<EchoSettings, "echoLength">} [settings=DefaultFilter.PluginEcho] The settings for the echo filter.
2372
- * @returns {Promise<boolean>} Whether the filter is now active.
2469
+ * @returns {Promise<this>} The instance of the filter manager.
2373
2470
  */
2374
2471
  async setEcho(settings = DefaultFilterPreset.PluginEcho) {
2375
2472
  validateNodePlugins(this.manager.player.node, ["lavalink-filter-plugin" /* FilterPlugin */]);
@@ -2385,13 +2482,13 @@ var LavalinkPluginFilter = class {
2385
2482
  this.manager.data.pluginFilters["lavalink-filter-plugin"].echo.decay = this.manager.filters.lavalinkFilterPlugin.echo ? 0 : settings.decay;
2386
2483
  this.manager.filters.lavalinkFilterPlugin.echo = !this.manager.filters.lavalinkFilterPlugin.echo;
2387
2484
  await this.manager.apply();
2388
- return this.manager.filters.lavalinkFilterPlugin.echo;
2485
+ return this;
2389
2486
  }
2390
2487
  /**
2391
2488
  *
2392
2489
  * Set the reverb filter with the given settings.
2393
2490
  * @param {Partial<LavalinkFilterPluginReverbSettings>} [settings=DefaultFilter.PluginReverb] The settings for the reverb filter.
2394
- * @returns {Promise<boolean>} Whether the filter is now active.
2491
+ * @returns {Promise<this>} The instance of the filter manager.
2395
2492
  */
2396
2493
  async setReverb(settings = DefaultFilterPreset.PluginReverb) {
2397
2494
  validateNodePlugins(this.manager.player.node, ["lavalink-filter-plugin" /* FilterPlugin */]);
@@ -2407,7 +2504,7 @@ var LavalinkPluginFilter = class {
2407
2504
  this.manager.data.pluginFilters["lavalink-filter-plugin"].reverb.gains = this.manager.filters.lavalinkFilterPlugin.reverb ? [] : settings.gains;
2408
2505
  this.manager.filters.lavalinkFilterPlugin.reverb = !this.manager.filters.lavalinkFilterPlugin.reverb;
2409
2506
  await this.manager.apply();
2410
- return this.manager.filters.lavalinkFilterPlugin.reverb;
2507
+ return this;
2411
2508
  }
2412
2509
  };
2413
2510
 
@@ -2482,18 +2579,9 @@ var FilterManager = class {
2482
2579
  this.plugin = new LavalinkPluginFilter(this);
2483
2580
  this.dspx = new DSPXPluginFilter(this);
2484
2581
  }
2485
- /**
2486
- *
2487
- * Checks if a custom filter is active.
2488
- * @returns {boolean} True if a custom filter is active, false otherwise.
2489
- */
2490
- isCustom() {
2491
- this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale ?? {}).some((d) => d !== 1);
2492
- return this.filters.custom;
2493
- }
2494
2582
  /**
2495
2583
  * Resets all filters to their default values.
2496
- * @returns {Promise<void>} A promise that resolves when the filters have been reset.
2584
+ * @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
2497
2585
  */
2498
2586
  async reset() {
2499
2587
  this.filters = {
@@ -2520,20 +2608,17 @@ var FilterManager = class {
2520
2608
  echo: false
2521
2609
  }
2522
2610
  };
2523
- for (const [key, value] of Object.entries(DefaultPlayerFilters)) {
2524
- this.data[key] = value;
2525
- }
2526
- await this.apply();
2611
+ this.data = { ...DefaultPlayerFilters };
2612
+ return this.apply();
2527
2613
  }
2528
2614
  /**
2529
2615
  *
2530
2616
  * Applies the current filters to the player.
2531
- * @returns {Promise<void>} A promise that resolves when the filters have been applied.
2617
+ * @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
2532
2618
  */
2533
2619
  async apply() {
2534
- if (!this.player.node.sessionId) return;
2620
+ if (!this.player.node.sessionId) return this;
2535
2621
  this.check();
2536
- this.isCustom();
2537
2622
  const filters = { ...this.data };
2538
2623
  if (!this.filters.volume) delete filters.volume;
2539
2624
  if (!this.filters.tremolo) delete filters.tremolo;
@@ -2560,6 +2645,7 @@ var FilterManager = class {
2560
2645
  if (!this.player.node.info?.filters?.includes(key)) delete filters[key];
2561
2646
  }
2562
2647
  await this.player.updatePlayer({ playerOptions: { filters } });
2648
+ return this;
2563
2649
  }
2564
2650
  /**
2565
2651
  * Checks if the current filters are active.
@@ -2581,6 +2667,7 @@ var FilterManager = class {
2581
2667
  this.filters.karaoke = Object.values(this.data.karaoke ?? {}).some((v) => v !== 0);
2582
2668
  this.filters.distortion = Object.values(this.data.distortion ?? {}).some((v) => v !== 0 && v !== 1);
2583
2669
  this.filters.timescale = Object.values(this.data.timescale ?? {}).some((v) => v !== 1);
2670
+ this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale ?? {}).some((d) => d !== 1);
2584
2671
  if ((this.filters.nightcore || this.filters.vaporwave) && timescale) {
2585
2672
  if (timescale.pitch !== this.data.timescale?.pitch || timescale.rate !== this.data.timescale?.rate || timescale.speed !== this.data.timescale?.speed) {
2586
2673
  this.filters.custom = Object.values(this.data.timescale ?? {}).some((v) => v !== 1);
@@ -2609,34 +2696,32 @@ var FilterManager = class {
2609
2696
  *
2610
2697
  * Sets the volume for the player.
2611
2698
  * @param {number} volume The volume level to set (between 0 and 5).
2612
- * @returns {Promise<boolean>} A promise that resolves to true if the volume was changed, false otherwise.
2699
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2613
2700
  */
2614
2701
  async setVolume(volume) {
2615
2702
  if (typeof volume !== "number" || Number.isNaN(volume) || volume < 0 || volume > 5)
2616
2703
  throw new PlayerError("Volume must be a number between 0 and 5.");
2617
2704
  this.data = { volume };
2618
2705
  this.filters.volume = volume !== 1;
2619
- await this.apply();
2620
- return this.filters.volume;
2706
+ return this.apply();
2621
2707
  }
2622
2708
  /**
2623
2709
  * Sets the audio output for the player.
2624
2710
  * @param {AudioOutput} output The audio output to set.
2625
- * @returns {Promise<AudioOutput>} A promise that resolves to the set audio output.
2711
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2626
2712
  */
2627
2713
  async setAudioOutput(output) {
2628
2714
  const outputs = Object.values(AudioOutput);
2629
2715
  if (!outputs.includes(output)) throw new PlayerError(`Audio output must be one of the following: ${outputs.join(", ")}.`);
2630
2716
  this.filters.audioOutput = output;
2631
2717
  this.data.channelMix = AudioOutputData[output];
2632
- await this.apply();
2633
- return this.filters.audioOutput;
2718
+ return this.apply();
2634
2719
  }
2635
2720
  /**
2636
2721
  *
2637
2722
  * Sets the speed for the player.
2638
2723
  * @param {number} speed The speed to set (default is 1).
2639
- * @returns {Promise<boolean>} A promise that resolves to true if a custom filter is active, false otherwise.
2724
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2640
2725
  */
2641
2726
  async setSpeed(speed = 1) {
2642
2727
  if (!this.player.node.info?.filters?.includes("timescale" /* Timescale */))
@@ -2651,14 +2736,13 @@ var FilterManager = class {
2651
2736
  this.filters.vaporwave = false;
2652
2737
  }
2653
2738
  this.data.timescale.speed = speed;
2654
- await this.apply();
2655
- return this.filters.custom;
2739
+ return this.apply();
2656
2740
  }
2657
2741
  /**
2658
2742
  *
2659
2743
  * Sets the rate for the player.
2660
2744
  * @param {number} rate The rate to set (default is 1).
2661
- * @returns {Promise<boolean>} A promise that resolves to true if a custom filter is active, false otherwise.
2745
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2662
2746
  */
2663
2747
  async setRate(rate = 1) {
2664
2748
  if (!this.player.node.info?.filters?.includes("timescale" /* Timescale */))
@@ -2673,14 +2757,13 @@ var FilterManager = class {
2673
2757
  this.filters.vaporwave = false;
2674
2758
  }
2675
2759
  this.data.timescale.rate = rate;
2676
- await this.apply();
2677
- return this.filters.custom;
2760
+ return this.apply();
2678
2761
  }
2679
2762
  /**
2680
2763
  *
2681
2764
  * Sets the pitch for the player.
2682
2765
  * @param {number} pitch The pitch
2683
- * @returns {Promise<boolean>} A promise that resolves to true if a custom filter is active, false otherwise.
2766
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2684
2767
  */
2685
2768
  async setPitch(pitch = 1) {
2686
2769
  if (!this.player.node.info?.filters?.includes("timescale" /* Timescale */))
@@ -2695,8 +2778,7 @@ var FilterManager = class {
2695
2778
  this.filters.vaporwave = false;
2696
2779
  }
2697
2780
  this.data.timescale.pitch = pitch;
2698
- await this.apply();
2699
- return this.filters.custom;
2781
+ return this.apply();
2700
2782
  }
2701
2783
  /**
2702
2784
  *
@@ -2709,8 +2791,7 @@ var FilterManager = class {
2709
2791
  if (!bands.length || !bands.every((band) => typeof band.band === "number" && typeof band.gain === "number"))
2710
2792
  throw new PlayerError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
2711
2793
  for (const { band, gain } of bands) this.bands[band] = { band, gain };
2712
- await this.apply();
2713
- return this;
2794
+ return this.apply();
2714
2795
  }
2715
2796
  /**
2716
2797
  *
@@ -2724,7 +2805,7 @@ var FilterManager = class {
2724
2805
  *
2725
2806
  * Set the vibrato filter with the given settings.
2726
2807
  * @param {TremoloSettings} [settings=DefaultFilterPreset.Vibrato] The settings for the vibrato filter.
2727
- * @returns {Promise<boolean>} Whether the filter is now active.
2808
+ * @returns {Promise<this>} The instance of the filter manager.
2728
2809
  */
2729
2810
  async setVibrato(settings = DefaultFilterPreset.Vibrato) {
2730
2811
  if (!this.player.node.info?.filters?.includes("vibrato" /* Vibrato */))
@@ -2734,14 +2815,13 @@ var FilterManager = class {
2734
2815
  depth: this.filters.vibrato ? 0 : settings.depth
2735
2816
  };
2736
2817
  this.filters.vibrato = !this.filters.vibrato;
2737
- await this.apply();
2738
- return this.filters.vibrato;
2818
+ return this.apply();
2739
2819
  }
2740
2820
  /**
2741
2821
  *
2742
2822
  * Set the tremolo filter with the given settings.
2743
2823
  * @param {TremoloSettings} [settings=DefaultFilterPreset.Tremolo] The settings for the tremolo filter.
2744
- * @returns {Promise<boolean>} Whether the filter is now active.
2824
+ * @returns {Promise<this>} The instance of the filter manager.
2745
2825
  */
2746
2826
  async setTremolo(settings = DefaultFilterPreset.Tremolo) {
2747
2827
  if (!this.player.node.info?.filters?.includes("tremolo" /* Tremolo */))
@@ -2751,27 +2831,25 @@ var FilterManager = class {
2751
2831
  depth: this.filters.tremolo ? 0 : settings.depth
2752
2832
  };
2753
2833
  this.filters.tremolo = !this.filters.tremolo;
2754
- await this.apply();
2755
- return this.filters.tremolo;
2834
+ return this.apply();
2756
2835
  }
2757
2836
  /**
2758
2837
  *
2759
2838
  * Set the low-pass filter with the given settings.
2760
2839
  * @param {LowPassSettings} [settings=DefaultFilterPreset.Lowpass] The settings for the low-pass filter.
2761
- * @returns {Promise<boolean>} Whether the filter is now active.
2840
+ * @returns {Promise<this>} The instance of the filter manager.
2762
2841
  */
2763
2842
  async setLowPass(settings = DefaultFilterPreset.Lowpass) {
2764
2843
  if (!this.player.node.info?.filters?.includes("lowPass" /* LowPass */))
2765
2844
  throw new PlayerError("Node filters does not include the 'lowPass' filter. (Or the node doesn't have it enabled)");
2766
2845
  this.data.lowPass = { smoothing: this.filters.lowPass ? 0 : settings.smoothing };
2767
2846
  this.filters.lowPass = !this.filters.lowPass;
2768
- await this.apply();
2769
- return this.filters.lowPass;
2847
+ return this.apply();
2770
2848
  }
2771
2849
  /**
2772
2850
  * Set the nightcore filter with the given settings.
2773
2851
  * @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Nightcore] The settings for the nightcore filter.
2774
- * @returns {Promise<boolean>} Whether the filter is now active.
2852
+ * @returns {Promise<this>} The instance of the filter manager.
2775
2853
  */
2776
2854
  async setNightcore(settings = DefaultFilterPreset.Nightcore) {
2777
2855
  if (!this.player.node.info?.filters?.includes("timescale" /* Timescale */))
@@ -2784,14 +2862,13 @@ var FilterManager = class {
2784
2862
  this.filters.nightcore = !this.filters.nightcore;
2785
2863
  this.filters.vaporwave = false;
2786
2864
  this.filters.custom = false;
2787
- await this.apply();
2788
- return this.filters.nightcore;
2865
+ return this.apply();
2789
2866
  }
2790
2867
  /**
2791
2868
  *
2792
2869
  * Set the vaporwave filter with the given settings.
2793
2870
  * @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Vaporwave] The settings for the vaporwave filter.
2794
- * @returns {Promise<boolean>} Whether the filter is now active.
2871
+ * @returns {Promise<this>} The instance of the filter manager.
2795
2872
  */
2796
2873
  async setVaporwave(settings = DefaultFilterPreset.Vaporwave) {
2797
2874
  if (!this.player.node.info?.filters?.includes("timescale" /* Timescale */))
@@ -2804,14 +2881,13 @@ var FilterManager = class {
2804
2881
  this.filters.vaporwave = !this.filters.vaporwave;
2805
2882
  this.filters.nightcore = false;
2806
2883
  this.filters.custom = false;
2807
- await this.apply();
2808
- return this.filters.vaporwave;
2884
+ return this.apply();
2809
2885
  }
2810
2886
  /**
2811
2887
  *
2812
2888
  * Set the karaoke filter with the given settings.
2813
2889
  * @param {KaraokeSettings} [settings=DefaultFilterPreset.Karaoke] The settings for the karaoke filter.
2814
- * @returns {Promise<boolean>} Whether the filter is now active.
2890
+ * @returns {Promise<this>} The instance of the filter manager.
2815
2891
  */
2816
2892
  async setKaraoke(settings = DefaultFilterPreset.Karaoke) {
2817
2893
  if (!this.player.node.info?.filters?.includes("karaoke" /* Karaoke */))
@@ -2823,14 +2899,13 @@ var FilterManager = class {
2823
2899
  filterWidth: this.data.karaoke.filterWidth ? 0 : settings.filterWidth
2824
2900
  };
2825
2901
  this.filters.karaoke = !this.filters.karaoke;
2826
- await this.apply();
2827
- return this.filters.karaoke;
2902
+ return this.apply();
2828
2903
  }
2829
2904
  /**
2830
2905
  *
2831
2906
  * Set the distortion filter with the given settings.
2832
2907
  * @param {Partial<DistortionSettings>} [settings=DefaultFilterPreset.Distortion] The settings for the distortion filter.
2833
- * @returns {Promise<boolean>} Whether the filter is now active.
2908
+ * @returns {Promise<this>} The instance of the filter manager.
2834
2909
  */
2835
2910
  async setDistortion(settings = DefaultFilterPreset.Distortion) {
2836
2911
  if (!this.player.node.info?.filters?.includes("distortion" /* Distortion */))
@@ -2845,13 +2920,12 @@ var FilterManager = class {
2845
2920
  scale: this.filters.distortion ? 1 : settings.scale
2846
2921
  };
2847
2922
  this.filters.distortion = !this.filters.distortion;
2848
- await this.apply();
2849
- return this.filters.distortion;
2923
+ return this.apply();
2850
2924
  }
2851
2925
  /**
2852
2926
  * Set the timescale filter with the given settings.
2853
2927
  * @param {Partial<TimescaleSettings>} settings The timescale settings to set.
2854
- * @returns {Promise<boolean>} Whether the filter is now active.
2928
+ * @returns {Promise<this>} The instance of the filter manager.
2855
2929
  */
2856
2930
  async setTimescale(settings) {
2857
2931
  if (!this.player.node.info?.filters?.includes("timescale" /* Timescale */))
@@ -2862,8 +2936,7 @@ var FilterManager = class {
2862
2936
  speed: settings.speed ?? 1
2863
2937
  };
2864
2938
  this.filters.timescale = !this.filters.timescale;
2865
- await this.apply();
2866
- return this.filters.timescale;
2939
+ return this.apply();
2867
2940
  }
2868
2941
  };
2869
2942
 
@@ -3623,7 +3696,7 @@ var QueueUtils = class {
3623
3696
  this.queue.player.manager.emit(
3624
3697
  "debug" /* Debug */,
3625
3698
  5 /* Queue */,
3626
- `[Queue] -> [Adapter] Saving queue for ${this.queue.player.guildId} | Object: ${JSON.stringify(json)}`
3699
+ `[Queue] -> [Adapter] Saving queue for ${this.queue.player.guildId} | Object: ${stringify(json)}`
3627
3700
  );
3628
3701
  return this.store.set(this.queue.player.guildId, json);
3629
3702
  }
@@ -3665,7 +3738,7 @@ var QueueUtils = class {
3665
3738
  this.queue.player.manager.emit(
3666
3739
  "debug" /* Debug */,
3667
3740
  5 /* Queue */,
3668
- `[Queue] -> [Adapter] Syncing queue for ${this.queue.player.guildId} | Object: ${JSON.stringify(data)}`
3741
+ `[Queue] -> [Adapter] Syncing queue for ${this.queue.player.guildId} | Object: ${stringify(data)}`
3669
3742
  );
3670
3743
  await this.save();
3671
3744
  }
@@ -4419,7 +4492,7 @@ var Hoshimi = class extends EventEmitter {
4419
4492
  this.emit(
4420
4493
  "debug" /* Debug */,
4421
4494
  1 /* Manager */,
4422
- `[Manager] -> [Search] Searching for: ${options.query} (${options.engine ?? "unknown"}) | Result: ${JSON.stringify(res)}`
4495
+ `[Manager] -> [Search] Searching for: ${options.query} (${options.engine ?? "unknown"}) | Result: ${stringify(res)}`
4423
4496
  );
4424
4497
  switch (res.loadType) {
4425
4498
  case "empty" /* Empty */: {
@@ -4503,6 +4576,7 @@ export {
4503
4576
  Queue,
4504
4577
  ResolveError,
4505
4578
  Rest,
4579
+ RestPathType,
4506
4580
  SearchEngines,
4507
4581
  Severity,
4508
4582
  SourceNames,