Skip to main content
Version: v2.9.2

Manager

Table of Contentsโ€‹

Class Definitionโ€‹

export class Manager extends EventEmitter {}

Propertiesโ€‹

Property Type Description
initiatedbooleanWhether the manager has been initiated.
nodesCollection<string, Node>The nodes.
optionsManagerOptionsThe manager options.
playersCollection<string, Player>>The players.
redis?RedisClientThe redis client.

Constructorโ€‹

new Manager(options: ManagerOptions)
Parameter Type Description Optional
optionsManagerOptionsThe manager options.

Methodsโ€‹

cleanupInactivePlayer()โ€‹

async cleanupInactivePlayer(guildId: string): Promise<void>

Cleans up an inactive player.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild id.

cleanupInactivePlayers()โ€‹

async cleanupInactivePlayers(): Promise<void>

Cleans up inactive players.


create()โ€‹

create(options: PlayerOptions): Player

Creates a player.

Parametersโ€‹

Parameter Type Description Optional
optionsPlayerOptionsThe player options.

Returnsโ€‹

Type Description
PlayerThe new player.

createNode()โ€‹

createNode(options: NodeOptions): Node

Creates a node.

Parametersโ€‹

Parameter Type Description Optional
optionsNodeOptionsThe node options.

Returnsโ€‹

Type Description
NodeThe new node.

decodeTrack()โ€‹

async decodeTrack(track: string): Promise<TrackData>

Decodes a track.

Parametersโ€‹

Parameter Type Description Optional
trackstringThe track.

Returnsโ€‹

Type Description
Promise<TrackData>The decoded track.

decodeTracks()โ€‹

async decodeTracks(tracks: string[]): Promise<TrackData[]>

Decodes multiple tracks.

Parametersโ€‹

Parameter Type Description Optional
tracksstring[]The tracks.

Returnsโ€‹

Type Description
Promise<TrackData[]>The decoded tracks.

destroy()โ€‹

async destroy(guildId: string): Promise<void>

Destroys a player.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild id.

destroyNode()โ€‹

async destroyNode(identifier: string): Promise<void>

Destroys a node.

Parametersโ€‹

Parameter Type Description Optional
identifierstringThe node identifier.

getPlayer()โ€‹

getPlayer(guildId: string): Player | undefined

Gets a player.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild id.

Returnsโ€‹

Type Description
Player | undefinedThe player.

handleShutdown()โ€‹

async handleShutdown(): Promise<void>

Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.


init()โ€‹

async init(options: ManagerInitOptions = {}): Promise<this>

Initializes the manager.

Parametersโ€‹

Parameter Type Description Optional
optionsManagerInitOptionsThe manager init options.

Returnsโ€‹

Type Description
Promise<this>The manager.

loadPlayerStates()โ€‹

async loadPlayerStates(nodeId: string): Promise<void>

Loads the player states.

Parametersโ€‹

Parameter Type Description Optional
nodeIdstringThe node id.

on()โ€‹

on<T extends keyof ManagerEvents>(event: T, listener: (...args: ManagerEvents[T]) => void): this

Adds an event listener.

Parametersโ€‹

Parameter Type Description Optional
eventT extends keyof DebugEvent | LyricsEvent | NodeEvents | PlayerEvents | SponsorBlockEvents | TrackEvents | VoiceReceiverEventsThe event.
listener(...args: any[]) => voidThe listener.

savePlayerState()โ€‹

async savePlayerState(guildId: string): Promise<void>

Saves the player state.

Parametersโ€‹

Parameter Type Description Optional
guildIdstringThe guild id.

async search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>

Searches for tracks.

Parametersโ€‹

Parameter Type Description Optional
querystring | SearchQueryThe query.
requesterT = unknownThe requester.

send()โ€‹

warning

โš ๏ธ This method is protected and should not be called directly.

send(packet: GatewayVoiceStateUpdate): unknown

Sends a packet to the discord gateway.

Parametersโ€‹

Parameter Type Description Optional
packetGatewayVoiceStateUpdateThe packet.

sendPacket()โ€‹

sendPacket(packet: GatewayVoiceStateUpdate): unknown

Sends a packet to the discord gateway.

Parametersโ€‹

Parameter Type Description Optional
packetGatewayVoiceStateUpdateThe packet.

resolveUser()โ€‹

resolveUser(user: PortableUser | string): Promise<PortableUser>

Resolves a PortableUser or ID to a real user object. Can be overridden by wrapper managers to return wrapper-specific User classes.

Parametersโ€‹

Parameter Type Description Optional
userPortableUser | stringThe packet.

updateVoiceState()โ€‹

async updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>

Updates the voice state.

Parametersโ€‹

Parameter Type Description Optional
dataVoicePacket | VoiceServer | VoiceStateThe data.

usableNode()โ€‹

usableNode(): Node

Returns the node to use based on the configured useNode and enablePriorityMode options.

Returnsโ€‹

Type Description
NodeThe node to use.