Player
No description provided
Player extends PlayerEventsEmitter<PlayerEvents>
Parameter | Type | Optional | Description |
---|---|---|---|
client | Client<boolean> | ❌ | The Discord Client |
options | PlayerInitOptions | ✅ | The player init options |
Properties
public client: any
The discord.js client
public events: any
The player events channel
public extractors: any
The extractors manager
public id: any
The unique identifier of this player instance
public lyrics: any
The lyrics api
public nodes: any
The player nodes (queue) manager
public options: any
The player options
public requiredEvents: any
public version: any
The player version
public voiceUtils: any
The voice api utilities
public static defaultMaxListeners: any
public static version: any
The version of discord-player
public context: any
The hooks context for this player instance.
public eventLoopLag: any
Event loop latency in ms. If your bot is laggy and this returns a number above 20ms for example, some expensive task is being executed on the current thread which is slowing down the event loop.
public hasDebugger: any
public queryCache: any
The current query cache provider in use
public queues: any
Alias to Player.nodes
.
Methods
public [iterator](): Generator<GuildQueue<unknown>void | unknown>
public addListener(name, listener): Player
Parameter | Type | Optional |
---|---|---|
name | K | ❌ |
listener | PlayerEvents[K] | ❌ |
public createPlaylist(data): Playlist
Creates Playlist
instance
Parameter | Type | Optional | Description |
---|---|---|---|
data | PlaylistInitData | ❌ | The data to initialize a playlist |
public debug(m): boolean
Parameter | Type | Optional |
---|---|---|
m | string | ❌ |
public destroy(): Promise<void>
Destroy every single queues managed by this master player instance
public emit(name, args): boolean
Parameter | Type | Optional |
---|---|---|
name | K | ❌ |
args | Parameters<PlayerEvents[K]> | ❌ |
public eventNames(): Array<U>
public generateStatistics(): GuildQueueStatistics
Generates statistics that could be useful. Statistics generator is still experimental.
public getMaxListeners(): number
public handleVoiceState(oldState, newState): void
Handles voice state update
Parameter | Type | Optional | Description |
---|---|---|---|
oldState | VoiceState | ❌ | The old voice state |
newState | VoiceState | ❌ | The new voice state |
public isCompatMode(): boolean
Whether the player is in compatibility mode. Compatibility mode is enabled when non-discord.js client is used.
public isVoiceStateHandlerLocked(): boolean
Checks if voice state handler is locked.
public listenerCount(type): number
Parameter | Type | Optional |
---|---|---|
type | keyof PlayerEvents | ❌ |
public listeners(type): Array<PlayerEvents[U]>
Parameter | Type | Optional |
---|---|---|
type | U | ❌ |
public lockVoiceStateHandler(): void
Lock voice state handler. When this method is called, discord-player will keep using the default voice state update handler, even if custom implementation exists.
public off(name, listener): Player
Parameter | Type | Optional |
---|---|---|
name | K | ❌ |
listener | PlayerEvents[K] | ❌ |
public on(name, listener): Player
Parameter | Type | Optional |
---|---|---|
name | K | ❌ |
listener | PlayerEvents[K] | ❌ |
public onVoiceStateUpdate(handler): void
Override default voice state update handler
Parameter | Type | Optional | Description |
---|---|---|---|
handler | VoiceStateHandler | ❌ | The handler callback |
public once(name, listener): Player
Parameter | Type | Optional |
---|---|---|
name | K | ❌ |
listener | PlayerEvents[K] | ❌ |
public play(channel, query, options): Promise<PlayerNodeInitializationResult<T>>
Initiate audio player
Parameter | Type | Optional | Description |
---|---|---|---|
channel | GuildVoiceChannelResolvable | ❌ | The voice channel on which the music should be played |
query | TrackLike | ❌ | The track or source to play |
options | PlayerNodeInitializerOptions<T> | ❌ | Options for player |
public prependListener(event, listener): this
Parameter | Type | Optional |
---|---|---|
event | U | ❌ |
listener | PlayerEvents[U] | ❌ |
public prependOnceListener(event, listener): this
Parameter | Type | Optional |
---|---|---|
event | U | ❌ |
listener | PlayerEvents[U] | ❌ |
public rawListeners(type): Array<PlayerEvents[U]>
Parameter | Type | Optional |
---|---|---|
type | U | ❌ |
public removeAllListeners(name?): Player
Parameter | Type | Optional |
---|---|---|
name | K | ✅ |
public removeListener(name, listener): Player
Parameter | Type | Optional |
---|---|---|
name | K | ❌ |
listener | PlayerEvents[K] | ❌ |
public scanDeps(): string
Generates a report of the dependencies used by the discord-voip
module. Useful for debugging.
public search(searchQuery, options): Promise<SearchResult>
Search tracks
Parameter | Type | Optional | Description |
---|---|---|---|
searchQuery | string | Playlist | Track<unknown>Array<Track<unknown>>SearchResult | ❌ | N/A |
options | SearchOptions | ❌ | The search options |
public setMaxListeners(n): this
Parameter | Type | Optional |
---|---|---|
n | number | ❌ |
public unlockVoiceStateHandler(): void
Unlock voice state handler. When this method is called, discord-player will stop using the default voice state update handler if custom implementation exists.
public static create(client, options): Player
Creates new discord-player instance.
Parameter | Type | Optional | Description |
---|---|---|---|
client | Client<boolean> | ❌ | The client that instantiated player |
options | PlayerInitOptions | ❌ | Player initializer options |