harmonylink
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -56,2 +56,3 @@ "use strict"; | ||
resumeTimeout: harmonylinkConfig.resumeTimeout ?? 10000, | ||
nodeAdder: harmonylinkConfig.nodeAdder ?? undefined, | ||
nodeResolver: harmonylinkConfig.nodeResolver ?? undefined, | ||
@@ -58,0 +59,0 @@ customAutoplay: harmonylinkConfig.customAutoplay ?? undefined, |
@@ -12,2 +12,8 @@ "use strict"; | ||
async addNode(node) { | ||
if (this.manager.options.nodeAdder) { | ||
const resolvedNode = await this.manager.options.nodeAdder(this, node); | ||
if (resolvedNode && resolvedNode instanceof Node_1.Node) | ||
return resolvedNode; | ||
} | ||
; | ||
const addedNode = new Node_1.Node(this.manager, node); | ||
@@ -14,0 +20,0 @@ this.set(node.name, addedNode); |
@@ -139,3 +139,3 @@ "use strict"; | ||
// Reconnect | ||
await this.connect(); | ||
await this.connect().catch(() => this.destroy()); | ||
// Restart the music if it was playing | ||
@@ -585,3 +585,3 @@ if (currentTrack && restartSong) { | ||
if ([4015, 4009, 4006].includes(data.code)) { | ||
return this.reconnect(!this.isPaused); | ||
return this.reconnect(!this.isPaused).catch(() => this.destroy()); | ||
} | ||
@@ -588,0 +588,0 @@ ; |
@@ -98,2 +98,8 @@ import AbstractLibraryClass from "../librarys/AbstractLibraryClass"; | ||
/** | ||
* A custom resolver for adding Nodes. | ||
* | ||
* @default undefined | ||
*/ | ||
nodeAdder?: (nodeManager: NodeManager, node: NodeGroup) => Promise<Node | void>; | ||
/** | ||
* A custom autoplay function to use for autoplaying tracks | ||
@@ -163,6 +169,7 @@ * | ||
} | ||
export type RequiredHarmonyLinkConfiguration = Omit<Required<HarmonyLinkConfiguration>, "customAutoplay" | "nodeResolver" | "nodes"> & { | ||
export type RequiredHarmonyLinkConfiguration = Omit<Required<HarmonyLinkConfiguration>, "customAutoplay" | "nodeAdder" | "nodeResolver" | "nodes"> & { | ||
nodes?: NodeGroup[]; | ||
customAutoplay: ((player: Player) => Promise<Player | void>) | undefined; | ||
nodeResolver: ((nodes: NodeManager) => Promise<Node | void>) | undefined; | ||
nodeAdder: ((nodeManager: NodeManager, node: NodeGroup) => Promise<Node | void>) | undefined; | ||
}; | ||
@@ -243,3 +250,3 @@ export interface HarmonyLinkEvents { | ||
* @param {Track} track The track that errored. | ||
* @param {{ op: "event"; guildId: string; } & (TrackExceptionEvent | TrackStuckEvent)} error The error that was sent. | ||
* @param {{ op: "event"; guildId: string; } & (TrackStuckEvent | TrackExceptionEvent)} error The error that was sent. | ||
* @returns {void} | ||
@@ -246,0 +253,0 @@ */ |
{ | ||
"name": "harmonylink", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "HarmonyLink: Seamlessly connect to LavaLink nodes for high-quality audio streaming in your applications. HarmonyLink offers a reliable and easy-to-use interface, perfect for building music bots and audio applications with superior performance.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -38,3 +38,3 @@ | ||
<a href="https://nodei.co/npm/harmonylink/"> | ||
<img src="https://nodei.co/npm/harmonylink.png?downloads=true&downloadRank=true&stars=true" alt="Poru NPM Package"/> | ||
<img src="https://nodei.co/npm/harmonylink.png?downloads=true&downloadRank=true&stars=true" alt="HarmonyLink NPM Package"/> | ||
</a> | ||
@@ -102,3 +102,3 @@ </div> | ||
// With Discord.js Version 14 | ||
import { DJSLibrary } from "HarmonyLink"; | ||
import { DJSLibrary, HarmonyLinkConfiguration, HarmonyLink } from "HarmonyLink"; | ||
import { Client } from "discord.js" | ||
@@ -122,6 +122,6 @@ | ||
const HarmonyLink = new HarmonyLink(config) | ||
const musicClient = new HarmonyLink(config) | ||
// Creating a player | ||
await HarmonyLink.createPlayer() | ||
await musicClient.createPlayer() | ||
``` | ||
@@ -128,0 +128,0 @@ |
@@ -44,2 +44,3 @@ import { HarmonyLinkConfiguration, RequiredHarmonyLinkConfiguration } from "@t/HarmonyLink"; | ||
resumeTimeout: harmonylinkConfig.resumeTimeout ?? 10000, | ||
nodeAdder: harmonylinkConfig.nodeAdder ?? undefined, | ||
nodeResolver: harmonylinkConfig.nodeResolver ?? undefined, | ||
@@ -46,0 +47,0 @@ customAutoplay: harmonylinkConfig.customAutoplay ?? undefined, |
@@ -15,2 +15,8 @@ import { Node } from "@/node/Node"; | ||
public async addNode(node: NodeGroup): Promise<Node> { | ||
if (this.manager.options.nodeAdder) { | ||
const resolvedNode = await this.manager.options.nodeAdder(this, node); | ||
if (resolvedNode && resolvedNode instanceof Node) return resolvedNode; | ||
}; | ||
const addedNode = new Node(this.manager, node); | ||
@@ -17,0 +23,0 @@ |
@@ -170,3 +170,3 @@ /* eslint-disable @typescript-eslint/restrict-template-expressions */ | ||
// Reconnect | ||
await this.connect(); | ||
await this.connect().catch(() => this.destroy()); | ||
@@ -632,3 +632,3 @@ // Restart the music if it was playing | ||
if ([4015, 4009, 4006].includes(data.code)) { | ||
return this.reconnect(!this.isPaused) | ||
return this.reconnect(!this.isPaused).catch(() => this.destroy()) | ||
}; | ||
@@ -635,0 +635,0 @@ |
@@ -110,2 +110,9 @@ /* eslint-disable @typescript-eslint/no-invalid-void-type */ | ||
/** | ||
* A custom resolver for adding Nodes. | ||
* | ||
* @default undefined | ||
*/ | ||
nodeAdder?: (nodeManager: NodeManager, node: NodeGroup) => Promise<Node | void>; | ||
/** | ||
* A custom autoplay function to use for autoplaying tracks | ||
@@ -180,3 +187,8 @@ * | ||
export type RequiredHarmonyLinkConfiguration = Omit<Required<HarmonyLinkConfiguration>, "customAutoplay" | "nodeResolver" | "nodes"> & { nodes?: NodeGroup[]; customAutoplay: ((player: Player) => Promise<Player | void>) | undefined; nodeResolver: ((nodes: NodeManager) => Promise<Node | void>) | undefined; }; | ||
export type RequiredHarmonyLinkConfiguration = Omit<Required<HarmonyLinkConfiguration>, "customAutoplay" | "nodeAdder" | "nodeResolver" | "nodes"> & { | ||
nodes?: NodeGroup[]; | ||
customAutoplay: ((player: Player) => Promise<Player | void>) | undefined; | ||
nodeResolver: ((nodes: NodeManager) => Promise<Node | void>) | undefined; | ||
nodeAdder: ((nodeManager: NodeManager, node: NodeGroup) => Promise<Node | void>) | undefined; | ||
}; | ||
@@ -264,3 +276,3 @@ export interface HarmonyLinkEvents { | ||
* @param {Track} track The track that errored. | ||
* @param {{ op: "event"; guildId: string; } & (TrackExceptionEvent | TrackStuckEvent)} error The error that was sent. | ||
* @param {{ op: "event"; guildId: string; } & (TrackStuckEvent | TrackExceptionEvent)} error The error that was sent. | ||
* @returns {void} | ||
@@ -267,0 +279,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
550937
9972