HarmonyLink Documentation
- README
- Globals
- HarmonyLink
- Node
- Player
- Queue
- Track
- Response
- ConnectionHandler
- WebSocketClosedEvent
- TrackStuckEvent
- TrackStartEvent
- TrackExceptionEvent
- TrackEndEvent
- TrackDataInfo
- SetStateUpdate
- PlayerOptions
- PlayerEvents
- NodeStats
- NodeOption
- NodeInfo
- NodeGroup
- NodeEvents
- LavalinkNodeStatsPacket
- HarmonyLinkRequesterOptions
- HarmonyLinkEvents
- HarmonyLinkConfiguration
- FrequenCInfo
- FiltersOptions
- ErrorResponses
- FailingAddresses
- DistortionOptions
- ConnectionOptions
- Config
- ChannelMixOptions
- NodeType
- DiscordVoiceStates
- PlayerConnectionState
- PlayerLoop
- VoiceConnectionState
- AbstractPlugin
- DJSLibrary
- ErisJS
- OceanicJS
- CamelToSnake
- DefaultOptions
- GetDefaultConnectionOptions
- GetDefaultNodeStats
- LoadPlugins
- ParseHarmonyLinkConfig
- ParseOptions
- SnakeToCamel
- AnyOtherPacket
- Band
- IPBlockType
- LavalinkPlayerUpdatePacket
- LavalinkReadyPacket
- NoPlaylistInfo
- PacketVoiceServerUpdate
- PacketVoiceStateUpdate
- PlayerEvent
- PlayerObjectFromAPI
- PlayerState
- PlaylistInfoFound
- ResolveOptions
- RoutePlannerStatusBIRP
- RoutePlannerStatusBase
- RoutePlannerStatusNIRP
- RoutePlannerStatusRIRP
- RoutePlannerStatusRNIP
- TrackData
- TrackLoadResultEmpty
- TrackLoadResultPlaylist
- TrackLoadResultSearch
- TrackLoadResultTrack
- TrackLoadingResultException
- UpdatePlayerInfo
- UpdatePlayerOptions
- UpdatePlayerTrack
- VoiceServer
- KaraokeOptions
- LowPassOptions
- RotationOptions
- TimescaleOptions
- TremoloOptions
- VibratoOptions
- EventData
- LavaLinkLoadTypes
- LavalinkEventPacket
- LavalinkPackets
- LoadTrackResult
- NodeLinkV2LoadTypes
- NodeOptions
- Packet
- PartialNull
- PlayerEventType
- PlaylistInfo
- RequiredHarmonyLinkConfiguration
- RoutePlannerStatus
- RoutePlannerStatusDisabled
- Severity
- Snowflake
- TDateISO
- TDateISODate
- TDateISOTime
- TDay
- THours
- TMilliseconds
- TMinutes
- TMonth
- TSeconds
- TYear
- TrackEndReason
- Config
HarmonyLinkConfiguration
harmonylink • Docs
harmonylink / HarmonyLinkConfiguration
Interface: HarmonyLinkConfiguration
Properties
additionalDriver?
optionaladditionalDriver:AbstractNodeDriver[]
Additional drivers to use for connecting to other nodes.
Note
If you are using a custom driver, you should extend AbstractNodeDriver and implement the methods.
Note
If you want, you can go onto our github and create a pull request to add your driver to the main repository so that it is supported by default.
Default
[]
Defined in
src/typings/HarmonyLink.ts:60
customAutoplay()?
optionalcustomAutoplay: (player) =>Promise<void|Player>
A custom autoplay function to use for autoplaying tracks
Parameters
• player: Player
Returns
Promise<void | Player>
Default
try {
const prevTrack = previousTrack ?? this.queue.previousTrack;
if (!prevTrack) return this;
switch (prevTrack.info.sourceName) {
case "soundcloud": {
const response = await this.resolve({ query: `${prevTrack.info.title}`, requester: prevTrack.info.requester, source: "scsearch" });
if (!response.tracks.length || response.tracks.length === 0 || ["error", "empty"].includes(response.loadType)) return await this.skip();
this.queue.add(response.tracks[Math.floor(Math.random() * Math.floor(response.tracks.length))]);
return await this.play();
};
case "youtube":
default: {
const searchedURL = `https://www.youtube.com/watch?v=${prevTrack.info.identifier || this.queue.currentTrack?.info.identifier}&list=RD${prevTrack.info.identifier || this.queue.currentTrack?.info.identifier}`;
const response = await this.resolve({ query: searchedURL, requester: prevTrack.info.requester, source: "ytmsearch" });
if (!response.tracks.length || response.tracks.length === 0 || ["error", "empty"].includes(response.loadType)) return await this.skip();
response.tracks.shift();
const track = response.tracks[Math.floor(Math.random() * Math.floor(response.tracks.length))];
this.queue.add(track);
return await this.play();
};
}
} catch {
return this.skip()
}
Defined in
src/typings/HarmonyLink.ts:148
defaultPlatform?
optionaldefaultPlatform:string
The default source (platform) to use for resolving tracks
Default
"ytsearch"
Defined in
src/typings/HarmonyLink.ts:162
defaultVolume?
optionaldefaultVolume:number
The default volume to use for players
Default
100
Defined in
src/typings/HarmonyLink.ts:155
library
library:
AbstractLibraryClass
The library instance used for interacting with the Discord client.
This should be an instance of a class extending AbstractLibraryClass.
import { DJSLibrary } from "HarmonyLink";
import { Client } from "discord.js"
// Initialize your client
const client = new Client();
const config: HarmonyLinkConfiguration = {
...YourConfiguration
library: new DJSLibrary(client),
}
Defined in
src/typings/HarmonyLink.ts:31
nodeResolver()?
optionalnodeResolver: (nodes) =>Promise<void|Node>
A custom resolver for the NodeResolver
Parameters
• nodes: NodeManager
Returns
Promise<void | Node>
Default
const nodes = this.allNodes;
const onlineNodes = nodes.filter(node => node.isConnected);
if (!onlineNodes || onlineNodes.length === 0) {
throw new Error("[HarmonyLink] [NodeManager] No nodes are online.");
};
const promises = onlineNodes.map(async node => {
const stats = await node.getStats();
return { node, stats };
});
const results = await Promise.all(promises);
const sorted = results.sort((a, b) => a.stats.players - b.stats.players);
return sorted[0].node;
Defined in
src/typings/HarmonyLink.ts:107
nodes
nodes:
NodeGroup[]
The nodes to use and connect to
Defined in
src/typings/HarmonyLink.ts:36
plugins?
optionalplugins:AbstractPlugin[]
Additional plugins to use for the library
Default
[]
Defined in
src/typings/HarmonyLink.ts:50
reconnectTimeout?
optionalreconnectTimeout:number
The timeout for the reconnect
Default
5000
Defined in
src/typings/HarmonyLink.ts:81
reconnectTries?
optionalreconnectTries:number
The amount of times to try to reconnect to the node
Default
5
Defined in
src/typings/HarmonyLink.ts:74
reconnectVoiceConnection?
optionalreconnectVoiceConnection:boolean
Reconnect the player when the voice connection is lost and recovered
Default
true
Defined in
src/typings/HarmonyLink.ts:176
resume?
optionalresume:boolean
Whether to automatically resume players when the node is reconnected (Note: DOES NOT RESUME WHEN THE LAVALINK SERVER DIES)
Default
true
Defined in
src/typings/HarmonyLink.ts:43
resumeTimeout?
optionalresumeTimeout:number
The timeout to use when resuming players
Default
10000
Defined in
src/typings/HarmonyLink.ts:67
voiceConnectionTimeout?
optionalvoiceConnectionTimeout:number
The timeout to use for voice connections
Default
10000
Defined in
src/typings/HarmonyLink.ts:169
