### Install @discord-player/equalizer
Source: https://github.com/androz2091/discord-player/blob/master/packages/equalizer/README.md
Install the equalizer package using yarn.
```sh
$ yarn add @discord-player/equalizer
```
--------------------------------
### Install @discord-player/utils
Source: https://github.com/androz2091/discord-player/blob/master/packages/utils/README.md
Install the @discord-player/utils package using yarn.
```sh
$ yarn add @discord-player/utils
```
--------------------------------
### Install @discord-player/ffmpeg
Source: https://github.com/androz2091/discord-player/blob/master/packages/ffmpeg/README.md
Install the FFmpeg stream abstraction package using Yarn.
```sh
yarn add @discord-player/ffmpeg
```
--------------------------------
### Install Discord Player and Extractors
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Install the main discord-player library and the extractors provider using npm.
```bash
npm install --save discord-player # main library
npm install --save @discord-player/extractor # extractors provider
```
--------------------------------
### Install FFmpeg/Avconv Binaries
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Install FFmpeg or Avconv for media transcoding. Official sources are recommended over npm binaries.
```bash
npm install --save ffmpeg-static
# or
npm install --save @ffmpeg-installer/ffmpeg
# or
npm install --save @node-ffmpeg/node-ffmpeg-installer
# or
npm install --save ffmpeg-binaries
```
--------------------------------
### Install Opus Library
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Install the mediaplex library for libopus and audio metadata extraction.
```bash
npm install --save mediaplex
```
--------------------------------
### Install Discord Player and Extractors
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/01_integrating.mdx
Install discord-player and its dependencies, including the default extractors for audio playback.
```bash
npm install discord-player @discord-player/extractor
```
--------------------------------
### Install @discord-player/opus
Source: https://github.com/androz2091/discord-player/blob/master/packages/opus/README.md
Install the core package using yarn. Ensure one of the compatible opus libraries is also installed.
```sh
yarn add @discord-player/opus
```
--------------------------------
### Setup Shared Audio Player
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/shared_audio_player.mdx
Use this setup to create a single audio player instance that can be shared across multiple queues. This is useful for radio streams or broadcasts where the same audio needs to be played in many guilds simultaneously. Note that commands like pause, play, or skip will affect all subscribers.
```javascript
const { createAudioPlayer } = require('discord-player');
const sharedAudioPlayer = createAudioPlayer();
// apply audio player while connecting. If the audio player was already playing, this connection will also start playing the audio in sync
if (!queue.connection)
await queue.connect(channel, {
audioPlayer: sharedAudioPlayer,
});
// only play if it is the initial play req
// future subscribers will automatically receive audio without having to play a track
if (thisIsInitialPlayRequest()) {
await queue.play(track, { queue: false });
}
// with player.play(), this is recommended for initial play only
await player.play(channel, query, {
connectionOptions: {
audioPlayer: sharedAudioPlayer,
},
});
```
--------------------------------
### Install FFmpeg Alternative Packages
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/index.mdx
Install FFmpeg or Avconv for media transcoding. Several npm packages are available, though official installation is recommended for stability.
```bash
npm install --save ffmpeg-static
```
```bash
npm install --save @ffmpeg-installer/ffmpeg
```
```bash
npm install --save @node-ffmpeg/node-ffmpeg-installer
```
```bash
npm install --save ffmpeg-binaries
```
--------------------------------
### Run Development Server
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/README.md
Use these commands to start the Next.js development server. Open http://localhost:3000 in your browser to view the site.
```bash
npm run dev
# or
pnpm dev
# or
yarn dev
```
--------------------------------
### Original Command Execution
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/03_player_context_setup.mdx
This is the standard line of code found in most command handlers before context setup.
```javascript
await command.execute(interaction);
```
--------------------------------
### Play Command Metadata Setup
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/adding_events.mdx
This snippet shows how to pass interaction channel as metadata when initiating playback, which is required for the `queue.metadata.send()` method used in general event listeners.
```javascript
await player.play(channel, query, {
nodeOptions: {
metadata: interaction.channel,
},
});
```
--------------------------------
### Execute Command
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Example of executing a command, typically used before adding discord-player's hooks.
```javascript
// execute the command
await command.execute(interaction);
```
--------------------------------
### playerStart
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/types/GuildQueueEvents.mdx
Emitted when the audio player starts streaming an audio track.
```APIDOC
## playerStart
### Description
Emitted when the audio player starts streaming audio track.
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Event Signature
`playerStart(queue: GuildQueue, track: Track) => unknown`
```
--------------------------------
### Get Player Instance
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/common_actions.mdx
Retrieve the main player instance from anywhere in your application. Ensure the player is initialized.
```javascript
const { useMainPlayer } = require("discord-player");
...
const player = useMainPlayer();
```
--------------------------------
### Run CommandKit Bot
Source: https://github.com/androz2091/discord-player/blob/master/apps/music-bot/README.md
Use this command to start your CommandKit bot in development mode.
```bash
npx commandkit dev
```
--------------------------------
### Instantiate AsyncQueue
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AsyncQueue.mdx
Creates a new instance of the AsyncQueue. This is the basic setup for using the queue.
```typescript
new AsyncQueue();
```
--------------------------------
### AudioPlayer.play(resource)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AudioPlayer.mdx
Starts playing a new audio resource. If a resource is already playing, it will be destroyed and replaced.
```APIDOC
## AudioPlayer.play(resource)
### Description
Plays a new resource on the player. If the player is already playing a resource, the existing resource is destroyed (it cannot be reused, even in another player) and is replaced with the new resource.
### Parameters
#### Path Parameters
- **resource** (AudioResource) - Required - The resource to play.
### Returns
- [void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)
```
--------------------------------
### Opus Encoding and Decoding Example
Source: https://github.com/androz2091/discord-player/blob/master/packages/opus/README.md
Demonstrates how to use OpusEncoder to convert PCM streams to Opus and OpusDecoder to convert Opus streams back to PCM. Ensure correct rate, channels, and frameSize are configured.
```js
import { OpusEncoder, OpusDecoder } from '@discord-player/opus';
// encode
const opusStream = getPcmStreamSomehow().pipe(new OpusEncoder({ rate: 48000, channels: 2, frameSize: 960 }));
// decode
const pcmStream = getOpusStreamSomehow().pipe(new OpusDecoder({ rate: 48000, channels: 2, frameSize: 960 }));
```
--------------------------------
### Install Opus Encoder Dependencies
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/faq/common_errors.mdx
Install one of the required opus encoder packages if you encounter 'mediaplex' or 'opusscript' not found errors. Choose the package manager command that suits your project setup.
```bash
npm i mediaplex
```
```bash
npm i @discordjs/opus
```
```bash
npm i opusscript
```
```bash
npm i node-opus
```
--------------------------------
### BaseExtractor activate Method
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/BaseExtractor.mdx
This method is called when the extractor is activated. It's intended for any setup logic required before the extractor starts processing queries.
```typescript
activate(): Promise
```
--------------------------------
### Initialize Discord Player Instance
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/index.mdx
Set up a Discord.js client with the necessary intents and initialize the Discord Player instance. Load all default extractors to enable various audio sources.
```javascript
const { Player } = require('discord-player');
const { DefaultExtractors } = require('@discord-player/extractor');
const client = new Discord.Client({
// Make sure you have 'GuildVoiceStates' intent enabled
intents: ['GuildVoiceStates' /* Other intents */],
});
// this is the entrypoint for discord-player based application
const player = new Player(client);
// Now, lets load all the default extractors
await player.extractors.loadMulti(DefaultExtractors);
```
--------------------------------
### Initialize FFmpeg with Options
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FFmpeg.mdx
Instantiate the FFmpeg class with optional configuration. The options parameter allows for customization of the FFmpeg process.
```typescript
new FFmpeg(options);
```
--------------------------------
### Setup Discord Player with Eris
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Configure Discord Player to work with the Eris client using the createErisCompat function.
```javascript
const { Player, createErisCompat } = require('discord-player');
const player = new Player(createErisCompat(client));
```
--------------------------------
### get(node)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildNodeManager.mdx
Retrieves an existing music queue for a given guild. Use this to access the current queue and its associated methods.
```APIDOC
## get(node)
### Description
Get existing queue.
### Method
`get`
### Parameters
#### Path Parameters
- **node** (NodeResolvable) - Required - Queue resolvable
### Returns
- null | GuildQueue - The GuildQueue instance if it exists, otherwise null.
```
--------------------------------
### Get Current Queue and Track
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/common_actions.mdx
Retrieve all tracks in the queue as an array and get the currently playing track.
```javascript
const { useQueue } = require("discord-player");
...
const queue = useQueue(interaction.guild.id);
const tracks = queue.tracks.toArray(); //Converts the queue into a array of tracks
const currentTrack = queue.currentTrack; //Gets the current track being played
```
--------------------------------
### Initialize Discord Player with Discord.js
Source: https://github.com/androz2091/discord-player/blob/master/packages/discord-player/README.md
Set up a main player instance for your Discord bot. Ensure the GuildVoiceStates intent is enabled.
```javascript
const { Player } = require('discord-player');
const { DefaultExtractors } = require('@discord-player/extractor');
const client = new Discord.Client({
// Make sure you have 'GuildVoiceStates' intent enabled
intents: ['GuildVoiceStates' /* Other intents */]
});
// this is the entrypoint for discord-player based application
const player = new Player(client);
// Now, lets load all the default extractors.
await player.extractors.loadMulti(DefaultExtractors);
```
--------------------------------
### useMainPlayer
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/functions/index.mdx
Fetch the main player instance.
```APIDOC
## useMainPlayer
### Description
Fetch main player instance
### Function Signature
```typescript
useMainPlayer()
```
```
--------------------------------
### Install Discord Player Extractors
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/02_extractors_integration.mdx
Install the `@discord-player/extractor` package using npm. This package provides default extractors for Discord Player.
```bash
npm install @discord-player/extractor
```
--------------------------------
### useMainPlayer
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/index.mdx
Fetch the main player instance.
```APIDOC
## useMainPlayer
### Description
Fetch main player instance
### Method
N/A (Function)
### Endpoint
N/A (Function)
### Parameters
N/A
### Request Example
N/A
### Response
N/A
```
--------------------------------
### getMaxListeners()
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/StreamDispatcher.mdx
Gets the maximum number of listeners that can be added to this dispatcher.
```APIDOC
## getMaxListeners()
### Description
Gets the maximum number of listeners that can be added to this dispatcher.
### Method
public
```
--------------------------------
### FFmpeg Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/ffmpeg/classes/FFmpeg.mdx
Initializes a new FFmpeg instance with the specified options.
```APIDOC
## new FFmpeg(options)
### Description
Initializes a new FFmpeg instance.
### Parameters
#### Path Parameters
- **options** (FFmpegOptions) - Required - Options to initialize ffmpeg
```
--------------------------------
### AudioPlayerIdleState
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-voip/types/index.mdx
The state that an AudioPlayer is in when it has no resource to play. This is the starting state.
```APIDOC
## AudioPlayerIdleState
### Description
The state that an AudioPlayer is in when it has no resource to play. This is the starting state.
### Type
This is a type definition and does not represent a direct API call.
```
--------------------------------
### FFmpeg Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FFmpeg.mdx
Initializes a new FFmpeg instance with optional configuration options.
```APIDOC
## FFmpeg Constructor
### Description
Initializes a new FFmpeg instance.
### Parameters
#### Path Parameters
- **options** (FFmpegOptions) - Optional - Options to initialize ffmpeg
```
--------------------------------
### Convert Frequency to String
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Get a string representation of the frequency value.
```typescript
frequency.toString();
```
--------------------------------
### Get Frequency in Decibels (dB)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Retrieve the frequency value in Decibels.
```typescript
frequency.dt();
```
--------------------------------
### Get Existing Voice Connection and Create Queue
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/using_existing_voice_connection.mdx
This snippet demonstrates how to retrieve an existing voice connection using its ID and then use it to play audio. It's useful when the connection might already exist and you need to re-establish it with the player.
```js
import { getVoiceConnection } from 'discord-voip'
const connection = getVoiceConnection(guildId);
const queue = await player.nodes.create(guild, {...});
queue.createDispatcher(connection);
// now use the queue
const { track } = await queue.play(query, { options });
```
--------------------------------
### Get Frequency in Megahertz (MHz)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Retrieve the frequency value in Megahertz.
```typescript
frequency.mhz();
```
--------------------------------
### Playlist Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Playlist.mdx
Initializes a new Playlist instance. It requires a Player instance and PlaylistInitData.
```APIDOC
## Playlist Constructor
### Description
Initializes a new Playlist instance. It requires a Player instance and PlaylistInitData.
### Parameters
#### Path Parameters
- **player** (Player) - Required - The player instance.
- **data** (PlaylistInitData) - Required - The data to initialize the playlist with.
```
--------------------------------
### Initialize Discord Player with discord.js
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/01_integrating.mdx
Initialize Discord Player for use with discord.js. Ensure you have the discord.js client set up.
```javascript
import { Client } from 'discord.js';
import { Player } from 'discord-player';
const client = new Client({
/* options */
});
const player = new Player(client);
```
--------------------------------
### Get Frequency in Kilohertz (kHz)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Retrieve the frequency value in Kilohertz.
```typescript
frequency.khz();
```
--------------------------------
### create(guild, options)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildNodeManager.mdx
Creates a music queue for a given guild if one does not already exist. This method is essential for initializing playback in a guild.
```APIDOC
## create(guild, options)
### Description
Create guild queue if it does not exist.
### Method
`create`
### Parameters
#### Path Parameters
- **guild** (GuildResolvable) - Required - The guild which will be the owner of the queue
- **options** (GuildNodeCreateOptions) - Required - Queue initializer options
### Returns
- GuildQueue - The newly created or existing GuildQueue instance.
```
--------------------------------
### Get Frequency in Hertz (Hz)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Retrieve the frequency value in Hertz.
```typescript
frequency.hz();
```
--------------------------------
### preResolve
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/QueryResolver.mdx
Pre-resolves redirect URLs to get the final destination URL.
```APIDOC
## static preResolve(query: string, maxDepth: number): Promise
### Description
Pre-resolve redirect urls.
### Parameters
#### Path Parameters
- **query** (string) - Required - The URL to pre-resolve.
- **maxDepth** (number) - Required - The maximum depth for resolving redirects.
```
--------------------------------
### Initialize Player with Oceanic Client
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/library-compatibility/using_oceanic.mdx
Wrap your Oceanic client with `createOceanicCompat` to create a proxy that mimics the Discord.js client. The original client is not mutated.
```javascript
const { Player, createOceanicCompat } = require('discord-player');
const { Client } = require('oceanic.js');
const client = new Client({
auth: 'Bot ...',
gateway: {
intents: ['GUILD_VOICE_STATES' /* Other intents */],
},
});
const player = new Player(createOceanicCompat(client));
```
--------------------------------
### PlayerInitOptions Configuration
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/types/PlayerInitOptions.mdx
This interface defines the available options for initializing the Discord Player. You can configure aspects like blocking specific extractors, setting connection timeouts, providing the FFmpeg path, adjusting lag monitoring intervals, and managing query caching.
```APIDOC
## PlayerInitOptions
### Properties
- **blockExtractors** (Array) - Optional - List of extractors to disable querying metadata from.
- **blockStreamFrom** (Array) - Optional - List of extractors to disable streaming from.
- **connectionTimeout** (number) - Optional - The voice connection timeout in milliseconds.
- **ffmpegPath** (string) - Optional - Configure the ffmpeg path.
- **lagMonitor** (number) - Optional - Time in ms to re-monitor event loop lag.
- **lockVoiceStateHandler** (boolean) - Optional - Prevent voice state handler from being overridden.
- **overrideFallbackContext** (boolean) - Optional - Whether to override the fallback context. Defaults to `true`.
- **probeTimeout** (number) - Optional - The probe timeout in milliseconds. Defaults to 5000.
- **queryCache** (null | QueryCacheProvider) - Optional - Query cache provider.
- **skipFFmpeg** (boolean) - Optional - Skip ffmpeg process when possible.
```
--------------------------------
### isReady()
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/StreamDispatcher.mdx
Checks if the voice connection is ready to play audio.
```APIDOC
## isReady()
### Description
Whether or not the voice connection is ready to play.
### Method
public
```
--------------------------------
### Get Collection as Array
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/utils/classes/Collection.mdx
Returns an array containing all the values stored in the collection.
```typescript
public array(): Array
```
--------------------------------
### Initialize Discord Player and Load Extractors
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Set up a new Discord Player instance with the Discord.js client and load default extractors. Ensure the GuildVoiceStates intent is enabled.
```javascript
const { Player } = require('discord-player');
const { DefaultExtractors } = require('@discord-player/extractor');
const client = new Discord.Client({
// Make sure you have 'GuildVoiceStates' intent enabled
intents: ['GuildVoiceStates' /* Other intents */],
});
// this is the entrypoint for discord-player based application
const player = new Player(client);
// Now, lets load all the default extractors.
await player.extractors.loadMulti(DefaultExtractors);
```
--------------------------------
### Get Raw Frequency Value
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Retrieve the raw numerical value of the frequency.
```typescript
frequency.valueOf();
```
--------------------------------
### Instantiate SoundCloudExtractor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/extractor/classes/SoundCloudExtractor.mdx
Initializes a new instance of the SoundCloudExtractor. Requires a context and optional initialization options.
```typescript
new SoundCloudExtractor(context, options);
```
--------------------------------
### Get Event Names
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Returns an array of all event names registered on the ExtractorExecutionContext.
```typescript
const eventNames = extractorExecutionContext.eventNames();
```
--------------------------------
### Activate SpotifyExtractor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/extractor/classes/SpotifyExtractor.mdx
Activates the SpotifyExtractor, likely performing setup operations before it can be used.
```typescript
activate()
```
--------------------------------
### PlayerSubscription Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-voip/classes/PlayerSubscription.mdx
Initializes a new PlayerSubscription instance. This requires a voice connection and an audio player to establish the subscription.
```APIDOC
## PlayerSubscription Constructor
### Description
Initializes a new PlayerSubscription instance. This requires a voice connection and an audio player to establish the subscription.
### Parameters
#### Path Parameters
- **connection** (VoiceConnection) - Required - The voice connection to subscribe to.
- **player** (AudioPlayer) - Required - The audio player to manage the subscription.
### Request Example
```typescript
new PlayerSubscription(connection, player);
```
```
--------------------------------
### Convert Frequency to JSON String
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Frequency.mdx
Get a JSON string representation of the frequency value.
```typescript
frequency.toJSON();
```
--------------------------------
### AudioPlayer Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AudioPlayer.mdx
Initializes a new AudioPlayer instance with optional configuration options.
```APIDOC
## new AudioPlayer(options)
### Description
Initializes a new AudioPlayer instance.
### Parameters
#### Path Parameters
- **options** (CreateAudioPlayerOptions) - Optional - Configuration options for creating the audio player.
```
--------------------------------
### AudioPlayer Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-voip/classes/AudioPlayer.mdx
Initializes a new AudioPlayer instance. Requires options to be provided.
```APIDOC
## new AudioPlayer(options)
### Description
Initializes a new AudioPlayer instance.
### Parameters
#### Path Parameters
- **options** (CreateAudioPlayerOptions) - Required - Options for creating the audio player.
```
--------------------------------
### resolveId
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Resolves the identifier for a given extractor. This can be used to get a unique string representation of an extractor.
```APIDOC
## public resolveId(resolvable): string
### Description
Resolve extractor identifier.
### Parameters
#### Path Parameters
- **resolvable** (ExtractorResolvable) - Required - The item to resolve an extractor identifier for.
```
--------------------------------
### Get Maximum Event Listeners
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Retrieves the maximum number of listeners allowed for any single event.
```typescript
const maxListeners = extractorExecutionContext.getMaxListeners();
```
--------------------------------
### Instantiate PlayerSubscription
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-voip/classes/PlayerSubscription.mdx
Create a new PlayerSubscription by providing the voice connection and the audio player. This establishes the link for audio streaming.
```typescript
new PlayerSubscription(connection, player);
```
--------------------------------
### AudioResource Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-voip/classes/AudioResource.mdx
Initializes a new instance of the AudioResource class.
```APIDOC
## AudioResource Constructor
### Description
Initializes a new instance of the AudioResource class.
### Parameters
#### Path Parameters
* **edges** (Array) - Required - The pipeline used to convert the input stream into a playable format.
* **streams** (Array) - Required - An object-mode Readable stream that emits Opus packets.
* **metadata** (Metadata) - Required - Optional metadata that can be used to identify the resource.
* **silencePaddingFrames** (number) - Required - The number of silence frames to append to the end of the resource's audio stream.
```
--------------------------------
### Get a Specific Extractor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Retrieves a specific extractor by its identifier. Returns undefined if the extractor is not found.
```typescript
const extractor = extractorExecutionContext.get(identifier);
```
--------------------------------
### Remove Track from Queue
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/common_actions.mdx
Remove a track from the queue by its index. Queue indices start from 0.
```javascript
const { useQueue } = require("discord-player");
...
const queue = useQueue(interaction.guild.id);
queue.removeTrack(trackNumber); //Remember queue index starts from 0, not 1
```
--------------------------------
### SequentialBucket Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/SequentialBucket.mdx
Initializes a new instance of the SequentialBucket class.
```APIDOC
## new SequentialBucket()
### Description
Initializes a new instance of the SequentialBucket class.
### Method
`new`
### Parameters
None
### Request Example
```typescript
new SequentialBucket();
```
### Response
None
```
--------------------------------
### SoundCloudExtractor Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/extractor/classes/SoundCloudExtractor.mdx
Initializes a new instance of the SoundCloudExtractor. It requires a context and optionally accepts initialization options.
```APIDOC
## new SoundCloudExtractor(context, options)
### Description
Initializes a new instance of the SoundCloudExtractor.
### Parameters
#### Path Parameters
- **context** (ExtractorExecutionContext) - Required - Context that instantiated this extractor
- **options** (SoundCloudExtractorInit) - Optional - Initialization options for this extractor
```
--------------------------------
### Instantiate BaseExtractor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/BaseExtractor.mdx
Initializes a new instance of the BaseExtractor class. Requires context and options for setup.
```typescript
new BaseExtractor(context, options);
```
--------------------------------
### Initialize Queue with Strategy and Initializer
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/utils/classes/Queue.mdx
Constructs a new Queue instance. Requires a QueueStrategy and an initial array of items.
```typescript
new Queue(strategy, initializer);
```
--------------------------------
### Register SoundCloud Extractor
Source: https://github.com/androz2091/discord-player/blob/master/packages/extractor/README.md
Use this snippet to enable the SoundCloud extractor for discord-player. Ensure you have the extractor installed.
```javascript
const { SoundCloudExtractor } = require('@discord-player/extractor');
const player = useMainPlayer();
// enables soundcloud extractor
player.extractors.register(SoundCloudExtractor);
```
--------------------------------
### Player Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Player.mdx
Initializes a new Player instance. Requires a Discord Client and optional PlayerInitOptions.
```APIDOC
## new Player(client, options)
### Description
Initializes a new Player instance.
### Parameters
#### Path Parameters
- **client** (Client) - Required - The Discord Client
- **options** (PlayerInitOptions) - Optional - The player init options
```
--------------------------------
### Wrap Command Execution with Player Context
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/03_player_context_setup.mdx
Wrap your command execution with a player context provider to manage player-specific features. Ensure `useMainPlayer` is called after player initialization.
```javascript
import { useMainPlayer } from 'discord-player';
```
```javascript
const player = useMainPlayer();
```
```javascript
const data = {
guild: interaction.guild,
};
```
```javascript
await player.context.provide(data, () => command.execute(interaction));
```
--------------------------------
### useContext
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/index.mdx
Get the current value of the context. If the context is lost and no default value is provided, undefined will be returned.
```APIDOC
## useContext
### Description
Get the current value of the context. If the context is lost and no default value is provided, undefined will be returned.
### Method
N/A (Function)
### Endpoint
N/A (Function)
### Parameters
N/A
### Request Example
N/A
### Response
N/A
```
--------------------------------
### SequentialBucket
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/index.mdx
Documentation for the SequentialBucket class.
```APIDOC
## Class: SequentialBucket
### Description
Provides documentation for the SequentialBucket class.
### Usage
```javascript
// Example usage of SequentialBucket
```
```
--------------------------------
### Instantiate SpotifyExtractor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/extractor/classes/SpotifyExtractor.mdx
Initializes a new instance of the SpotifyExtractor. Requires a context and accepts optional initialization options.
```typescript
new SpotifyExtractor(context, options);
```
--------------------------------
### useContext
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/functions/index.mdx
Get the current value of the context. If the context is lost and no default value is provided, undefined will be returned.
```APIDOC
## useContext
### Description
Get the current value of the context. If the context is lost and no default value is provided, undefined will be returned.
### Function Signature
```typescript
useContext(context: Context, defaultValue?: any)
```
### Parameters
#### Path Parameters
- **context** (Context) - The context to retrieve the value from.
- **defaultValue** (any) - Optional. The default value to return if the context is lost.
```
--------------------------------
### Get Data from QueryCache
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/QueryCache.mdx
Retrieves all cached data. Returns a Promise that resolves to an array of cached results.
```typescript
getData()
```
--------------------------------
### Get Lyrics by ID
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/LrcLib.mdx
Retrieves lyrics directly using their unique ID. The ID must be a number.
```typescript
lrcLib.getById(id);
```
--------------------------------
### FFmpeg.spawn
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/ffmpeg/classes/FFmpeg.mdx
Spawns a new FFmpeg process with the given options.
```APIDOC
## FFmpeg.spawn(options)
### Description
Spawns ffmpeg process.
### Method
static spawn
### Parameters
#### Path Parameters
- **options** (FFmpegSpawnOptions) - Required - Spawn options
### Returns
- **ChildProcessWithoutNullStreams** - The spawned FFmpeg child process.
```
--------------------------------
### Creating and Using a Context
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/functions/createContext.mdx
Demonstrates how to create a context, provide a value to it, and then consume that value within a handler function. This is useful for managing and sharing state across different parts of your application.
```typescript
const userContext = createContext();
// the value to provide
const user = {
id: 1,
name: 'John Doe',
};
// provide the context value to the receiver
context.provide(user, handler);
function handler() {
// get the context value
const { id, name } = useContext(context);
console.log(id, name); // 1, John Doe
}
```
--------------------------------
### Get a Guild Queue
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildNodeManager.mdx
Retrieves an existing guild queue. Returns the GuildQueue object or null if not found.
```typescript
guildNodeManager.get(node);
```
--------------------------------
### Spawn FFmpeg Process
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FFmpeg.mdx
Initiate an FFmpeg process with specified options. This method is used internally to run FFmpeg commands for audio processing.
```typescript
FFmpeg.spawn(options?);
```
--------------------------------
### Get Gain for a Band
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/EqualizerConfiguration.mdx
Retrieve the current gain value for a specified frequency band. The band must be a number.
```typescript
getGain(band);
```
--------------------------------
### Get Extractor Execution ID
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Retrieves the unique identifier for the current extractor execution. Returns null if not set.
```typescript
const executionId = extractorExecutionContext.getExecutionId();
```
--------------------------------
### createPlaylist
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Player.mdx
Creates a Playlist instance with the provided data.
```APIDOC
## createPlaylist(data)
### Description
Creates `Playlist` instance.
### Parameters
#### Path Parameters
- **data** (PlaylistInitData) - Required - The data to initialize a playlist.
```
--------------------------------
### Get Extractor Execution Context
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Retrieves the current execution context for extractors. Returns null if no context is available.
```typescript
const context = extractorExecutionContext.getContext();
```
--------------------------------
### Assign Player to Client (Not Recommended)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/faq/how_to_access_player.mdx
Directly assigning the player instance to `client.player` can lead to intellisense issues as the `client` object does not natively have this property.
```javascript
client.player = player;
```
--------------------------------
### Key Mirror Utility
Source: https://github.com/androz2091/discord-player/blob/master/packages/utils/README.md
Shows how to use the keyMirror utility to create read-only objects where keys and values are identical. Useful for creating enum-like structures.
```ts
import { keyMirror } from "@discord-player/utils";
// creates read-only object with same value as the key
const enums = keyMirror([
"SUNDAY",
"MONDAY",
"TUESDAY"
]);
console.log(enums);
/*
{
"SUNDAY": "SUNDAY",
"MONDAY": "MONDAY",
"TUESDAY": "TUESDAY"
}
*/
```
--------------------------------
### getRuntime
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Util.mdx
Gets the runtime information for the Discord Player. This can include details about the Node.js version, library version, and other environment-specific data.
```APIDOC
## public static getRuntime()
### Description
Gets the runtime information.
### Returns
- Runtime - An object containing runtime information.
```
--------------------------------
### Join Voice Channel and Create Queue
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/using_existing_voice_connection.mdx
Use this snippet when you have manually joined a voice channel and want to use that existing connection to play audio. Ensure you create the queue and then associate the dispatcher with the existing connection.
```js
import { joinVoiceChannel } from 'discord-voip'
const connection = joinVoiceChannel(...);
const queue = await player.nodes.create(guild, {...});
queue.createDispatcher(connection);
// now use the queue
const { track } = await queue.play(query, { options });
```
--------------------------------
### Initialize FFmpeg Transcoder
Source: https://github.com/androz2091/discord-player/blob/master/packages/ffmpeg/README.md
Initialize a new FFmpeg transcoder instance with custom arguments for audio processing. Ensure FFmpeg is accessible via environment variables or system PATH.
```javascript
import { FFmpeg } from '@discord-player/ffmpeg';
const transcoder = new FFmpeg({
args: [
'-analyzeduration', '0',
'-loglevel', '0',
'-f', 's16le',
'-ar', '48000',
'-ac', '2',
'-af', 'bass=g=15,acompressor'
]
});
const stream = getAudioStreamSomehow();
const transcoded = stream.pipe(transcoder);
```
--------------------------------
### Get Duration Multiplier
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildQueuePlayerNode.mdx
Retrieves the duration multiplier for the current playback. This might be used for specific audio processing or effects.
```typescript
getDurationMultiplier(): number;
```
--------------------------------
### LrcLib Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/LrcLib.mdx
Initializes a new LrcLib instance with a player.
```APIDOC
## new LrcLib(player)
### Description
Initializes a new LrcLib instance.
### Parameters
#### Path Parameters
- **player** (Player) - Required - The player instance
```
--------------------------------
### Get Enabled Filters
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FFmpegFilterer.mdx
Retrieves a list of all FFmpeg filters that are currently enabled. This helps in identifying which audio effects are active.
```typescript
getFiltersEnabled();
```
--------------------------------
### Play Raw Resource
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/playing_raw_resource.mdx
Use `createAudioResource` to create an audio resource and then play it using the player. Ensure you import `createAudioResource` from 'discord-voip'.
```javascript
import { createAudioResource } from 'discord-voip';
const resource = createAudioResource(...); // create audio resource
await player.play(resource); // play that resource
```
--------------------------------
### Insert Track into Queue
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/common-actions/common_actions.mdx
Insert a new track at a specific position in the queue. Remember that queue indices start from 0.
```javascript
const { useQueue, useMainPlayer } = require("discord-player");
...
const player = useMainPlayer();
const queue = useQueue(interaction.guild.id);
const searchResult = await player.search(query, { requestedBy: interaction.user });
queue.insertTrack(searchResult.tracks[0], position); //Remember queue index starts from 0, not 1
```
--------------------------------
### Instantiate AudioPlayer
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AudioPlayer.mdx
Creates a new instance of the AudioPlayer. Options can be provided to configure the player.
```typescript
new AudioPlayer(options);
```
--------------------------------
### Playlist.fromSerialized()
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Playlist.mdx
Creates a new Playlist instance from serialized data. This is useful for reconstructing playlist objects, for example, after fetching them from storage.
```APIDOC
## public static fromSerialized(player, data): Playlist
### Description
Deserialize this playlist from serialized data.
### Parameters
#### Query Parameters
- **player** (Player) - Required - Player instance
- **data** (SerializedPlaylist) - Required - Serialized data
```
--------------------------------
### Instantiate Playlist
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Playlist.mdx
Creates a new Playlist instance. Requires the Player instance and playlist data.
```typescript
new Playlist(player, data);
```
--------------------------------
### play(channel, query, options)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Player.mdx
Initiates audio playback in a voice channel.
```APIDOC
## play(channel, query, options)
### Description
Initiates audio playback in a voice channel.
### Parameters
#### Path Parameters
- **channel** (GuildVoiceChannelResolvable) - Required - The voice channel on which the music should be played.
- **query** (TrackLike) - Required - The track or source to play.
- **options** (PlayerNodeInitializerOptions) - Required - Options for the player.
### Returns
- Promise> - A promise that resolves with the initialization result of the player node.
```
--------------------------------
### Collection Data Structure
Source: https://github.com/androz2091/discord-player/blob/master/packages/utils/README.md
Illustrates the use of the Collection utility, a Map-based data structure. Set, get, and delete key-value pairs.
```ts
import { Collection } from "@discord-player/utils";
// utility data structure based on Map
const store = new Collection();
store.set("foo", 1);
console.log(store.get("foo")); // 1
store.delete("foo"); // true
console.log(store.get("foo")); // undefined
store.delete("foo"); // false
```
--------------------------------
### Create a new audio stream with filters
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FiltersChain.mdx
The create method initializes a new audio stream with optional filters. It requires a source stream and can accept a presets object to apply specific audio effects.
```typescript
create(src, presets?): Readable
```
--------------------------------
### Get Voice Connection
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/VoiceUtils.mdx
Retrieves the current Discord Player voice connection for a given guild. An optional group identifier can be provided.
```typescript
getConnection(guild, group?): undefined | VoiceConnection
```
--------------------------------
### Instantiate PCMResampler
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/PCMResampler.mdx
Create a new instance of PCMResampler. The constructor accepts an optional options object.
```typescript
new PCMResampler(options);
```
--------------------------------
### Get Timestamp
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildQueuePlayerNode.mdx
Obtains the current playback timestamp, indicating the progress within the audio track. Can optionally ignore active filters.
```typescript
getTimestamp(ignoreFilters: boolean): null | PlayerTimestamp;
```
--------------------------------
### Get Cached Lyrics
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/LrcLib.mdx
Fetches lyrics from the cache using provided parameters. This can be faster than fetching from the API if lyrics are already stored.
```typescript
lrcLib.getCached(params);
```
--------------------------------
### Queue Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/utils/classes/Queue.mdx
Initializes a new Queue instance with a specified strategy and an initial array of items.
```APIDOC
## new Queue(strategy, initializer)
### Description
Initializes a new Queue instance.
### Parameters
#### Path Parameters
- **strategy** (QueueStrategy) - Required - The queue strategy to use.
- **initializer** (Array) - Required - An array of items to initialize the queue with.
```
--------------------------------
### PlayerNodeInitializerOptions
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/types/PlayerNodeInitializerOptions.mdx
The PlayerNodeInitializerOptions type defines the configuration options available for search engines when initializing a player node. This includes options for request configuration, the user who requested the search, and the specific search engine to be used.
```APIDOC
## PlayerNodeInitializerOptions
This type represents the options that can be passed to initialize a player node, specifically related to search engine configurations.
### Properties
- **requestOptions** (any) - Optional - Allows for custom configuration of the underlying request engine. This can be used to pass specific options to the search engine.
- **requestedBy** (UserResolvable) - Optional - Specifies the user who initiated the search. This is useful for logging or permission checks.
- **searchEngine** (SearchQueryType | `ext:${string}`) - Optional - Defines the search engine to be used. It can be a predefined `SearchQueryType` or a custom extractor by prefixing with `ext:`.
- **signal** (AbortSignal) - Optional - An AbortSignal that can be used to cancel the search operation.
```
--------------------------------
### Get Lyrics by Parameters
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/LrcLib.mdx
Fetches lyrics using provided parameters. Ensure the 'params' object is correctly formatted according to LrcGetParams.
```typescript
lrcLib.get(params);
```
--------------------------------
### Get Task from AsyncQueueEntry
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AsyncQueueEntry.mdx
Retrieves the task associated with the AsyncQueueEntry. This method returns a Promise that resolves with the task, allowing for asynchronous execution.
```typescript
getTask();
```
--------------------------------
### Initialize Discord Player with Eris Client
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/library-compatibility/using_eris.mdx
Wrap your Eris client with `createErisCompat` to create a proxy that mimics the Discord.js client. The original Eris client is not mutated.
```javascript
const { Player, createErisCompat } = require('discord-player');
const Eris = require('eris');
const client = new Eris('...');
const player = new Player(createErisCompat(client));
```
--------------------------------
### FFmpeg.spawn
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FFmpeg.mdx
Spawns a new FFmpeg process with specified options.
```APIDOC
## FFmpeg.spawn(options?)
### Description
Spawns ffmpeg process.
### Method
static
### Parameters
#### Path Parameters
- **options** ({ args: Array, shell: boolean }) - Optional - Spawn options
- **args** (Array) - Required - Arguments to pass to FFmpeg
- **shell** (boolean) - Required - Whether to spawn FFmpeg in a shell
### Returns
- **ChildProcessWithoutNullStreams**
```
--------------------------------
### Get Disabled Filters
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/FFmpegFilterer.mdx
Retrieves a list of all FFmpeg filters that are currently disabled. This can be useful for understanding the active audio processing pipeline.
```typescript
getFiltersDisabled();
```
--------------------------------
### SpotifyExtractor Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/extractor/classes/SpotifyExtractor.mdx
Initializes a new instance of the SpotifyExtractor class. It requires an ExtractorExecutionContext and accepts optional SpotifyExtractorInit options.
```APIDOC
## new SpotifyExtractor(context, options)
### Description
Initializes a new instance of the SpotifyExtractor class.
### Parameters
#### Path Parameters
- **context** (ExtractorExecutionContext) - Required - Context that instantiated this extractor
- **options** (SpotifyExtractorInit) - Optional - Initialization options for this extractor
```
--------------------------------
### Get Player Instance and Song Query
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/04_creating_a_play_command.mdx
Retrieve the Discord Player instance using useMainPlayer and extract the song query from the interaction options.
```javascript
import { useMainPlayer } from 'discord-player';
export async function execute(interaction) {
const player = useMainPlayer();
const query = interaction.options.getString('song', true);
}
```
--------------------------------
### Player.create
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/Player.mdx
Creates a new instance of the Player class, initializing it with a Discord client and optional configuration.
```APIDOC
## static create(client, options): Player
Creates new discord-player instance.
### Parameters
#### Path Parameters
- **client** (Client) - Required - The client that instantiated player
- **options** (PlayerInitOptions) - Required - Player initializer options
### Source
[Source](https://github.com/androz2091/discord-player/blob/ce04b3f4c6671029ce4d4aa9090e56ac7e7f5666/packages/discord-player/src/Player.ts#L238)
```
--------------------------------
### Get an Audio Filter
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AudioFilters.mdx
Retrieves the FFmpeg arguments for a specific audio filter by its name. This can be used to inspect or reuse existing filter configurations.
```typescript
AudioFilters.get('bassboost');
```
--------------------------------
### PlayerNodeInitializerOptions
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/types/PlayerNodeInitializerOptions.mdx
The PlayerNodeInitializerOptions interface defines the structure for configuring a PlayerNode. It allows customization of various aspects such as search result processing, audio player behavior, connection settings, and more.
```APIDOC
## PlayerNodeInitializerOptions
### Properties
- **afterSearch** ( ( result: SearchResult ) => Promise ) - Optional - A function to process search results before they are used.
- **audioPlayerOptions** ( ResourcePlayOptions ) - Optional - Options for configuring the audio player.
- **blockExtractors** ( Array ) - Optional - A list of extractors to block from being used.
- **connectionOptions** ( VoiceConnectConfig ) - Optional - Configuration options for the voice connection.
- **fallbackSearchEngine** ( 'soundcloud' | 'youtube' | 'arbitrary' | 'auto' | 'youtubePlaylist' | 'soundcloudTrack' | 'soundcloudPlaylist' | 'spotifySong' | 'spotifyAlbum' | 'spotifyPlaylist' | 'spotifySearch' | 'facebook' | 'vimeo' | 'reverbnation' | 'youtubeSearch' | 'youtubeVideo' | 'soundcloudSearch' | 'appleMusicSong' | 'appleMusicAlbum' | 'appleMusicPlaylist' | 'appleMusicSearch' | 'file' | 'autoSearch' ) - Optional - The fallback search engine to use when the primary one fails.
- **ignoreCache** ( boolean ) - Optional - If true, the query cache lookup will be ignored.
- **nodeOptions** ( GuildNodeCreateOptions ) - Optional - Options for creating the guild node.
```
--------------------------------
### Play Audio Resource
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/AudioPlayer.mdx
Starts playing a new audio resource. If the player is already playing something, the current resource will be destroyed and replaced.
```typescript
player.play(resource);
```
--------------------------------
### Initialize Equalizer
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Equalizer.mdx
Instantiate the Equalizer class with the desired channel count and an array of band multipliers. Ensure both parameters are provided as they are not optional.
```typescript
new Equalizer(channelCount, bandMultipliers);
```
--------------------------------
### Load Specific Named Extractors
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/02_extractors_integration.mdx
Load only specific extractors, such as `SoundCloudExtractor` and `AttachmentExtractor`, by passing an array of their constructors to `player.extractors.loadMulti`. This allows for a more tailored setup.
```javascript
import {
SoundCloudExtractor,
AttachmentExtractor,
} from '@discord-player/extractor';
await player.extractors.loadMulti([SoundCloudExtractor, AttachmentExtractor]);
```
--------------------------------
### Accessing the Main Player Instance
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/hooks/using_hooks.mdx
Use the `useMainPlayer` hook to get the main player instance, which manages all guild queues and global player settings.
```javascript
const { useMainPlayer } = require('discord-player');
// Get the player instance
const player = useMainPlayer();
```
--------------------------------
### Initialize Discord Player with Eris
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/docs/creating-a-music-bot/01_integrating.mdx
Initialize Discord Player for use with Eris. This requires creating an Eris client and then a compat layer for Discord Player.
```javascript
import Eris from 'eris';
import { Player, createErisCompat } from 'discord-player';
const client = Eris({
/* options */
});
const player = new Player(createErisCompat(client));
```
--------------------------------
### Get GuildQueueHistory Size
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildQueueHistory.mdx
Retrieves the number of tracks currently stored in the playback history. This method returns a number representing the count of historical tracks.
```typescript
getSize(): number;
```
--------------------------------
### playOpusPacket(buffer)
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-voip/classes/VoiceConnection.mdx
Prepares an audio packet and dispatches it immediately.
```APIDOC
## playOpusPacket(buffer)
### Description
Prepares an audio packet and dispatches it immediately.
### Parameters
#### Path Parameters
- **buffer** (Buffer) - Required - The Opus packet to play.
### Returns
- undefined | boolean - Indicates if the operation was successful.
```
--------------------------------
### AppleMusicExtractor Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/extractor/classes/AppleMusicExtractor.mdx
Initializes a new instance of the AppleMusicExtractor. It requires a context and accepts optional initialization options.
```APIDOC
## new AppleMusicExtractor(context, options)
### Parameters
#### Path Parameters
- **context** (ExtractorExecutionContext) - Required - Context that instantiated this extractor
- **options** (AppleMusicExtractorInit) - Optional - Initialization options for this extractor
```
--------------------------------
### Play Next Track
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/GuildQueueHistory.mdx
Initiates playback of the next track in the queue. This method is asynchronous and returns a Promise that resolves when the next track starts playing.
```typescript
next(): Promise;
```
--------------------------------
### Listen for Player Start Event
Source: https://github.com/androz2091/discord-player/blob/master/README.md
Add an event listener to notify users when a new track begins playing. The channel is accessed via queue.metadata.channel.
```javascript
// this event is emitted whenever discord-player starts to play a track
player.events.on('playerStart', (queue, track) => {
// we will later define queue.metadata object while creating the queue
queue.metadata.channel.send(`Started playing **${track.cleanTitle}**!`);
});
```
--------------------------------
### ExtractorExecutionContext Constructor
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/discord-player/classes/ExtractorExecutionContext.mdx
Initializes a new instance of the ExtractorExecutionContext class. It requires a Player instance as an argument.
```APIDOC
## new ExtractorExecutionContext(player)
### Description
Initializes a new instance of the ExtractorExecutionContext class.
### Parameters
#### Path Parameters
- **player** (Player) - Required - The Player instance to associate with this context.
```
--------------------------------
### Get Equalizer Band Gain
Source: https://github.com/androz2091/discord-player/blob/master/apps/website/content/api/equalizer/classes/Equalizer.mdx
Retrieve the gain value for a specific audio band using the getGain method. The band parameter must be a number and is not optional.
```typescript
equalizer.getGain(band);
```