Discord Player is a comprehensive, feature-rich framework designed to facilitate music commands within Discord bots using discord.js. The current stable version is 7.2.0, with an active release cadence addressing features, bug fixes, and compatibility. Key differentiators include its robust queue management, support for various audio sources via the `@discord-player/extractor` ecosystem, stream interception API for advanced audio processing, a dedicated lyrics API, and a flexible hooks API for simplified state management. Version 7 introduced a significant rewrite focusing on improved architecture and performance, requiring a migration for users upgrading from v6. It supports modern JavaScript/TypeScript development and aims to provide a stable foundation for complex music bot functionalities.
npm install discord-playerVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes a Discord bot, sets up the discord-player, loads default extractors, and demonstrates how to play a song from a user's query when they are in a voice channel. It includes error handling and basic bot setup.
Refer to the official migration guide for v7 (discord-player.js.org/docs/migrating/migrating_to_v7) to update your bot's codebase.
Ensure you have `@discord-player/extractor` installed. For specific sources, check the discord-player documentation for required plugins or `player.extractors.loadDefault()`.
Review the v7 documentation for how to configure audio options. Many previous `ytdlOptions` are now managed by the player or specific extractors, or through stream interceptors.
Always check the `discord-player` documentation and release notes for recommended `discord.js` versions. Keep both packages updated in tandem.
Install `ffmpeg` on your system and ensure it's accessible in the environment where your bot runs. On Linux/macOS, use your package manager. For Windows, add it to your PATH.
Ensure the user is in a voice channel and the `voiceChannel` variable is not `null` or `undefined`. Also, verify `new Player(client)` was called and `player.extractors.loadDefault()` is executed before attempting to play.
Install `ffmpeg` on your system. For example, `sudo apt install ffmpeg` on Debian/Ubuntu, `brew install ffmpeg` on macOS, or download from the official FFmpeg website and add to PATH on Windows.
Ensure `@discord-player/extractor` is installed and `player.extractors.loadDefault()` is called. If using a specific source, confirm the corresponding extractor is installed and enabled (e.g., for Spotify, make sure the Spotify extractor is working).
Update your imports to use ES Module syntax: `import { Player } from 'discord-player';`. If you must use CommonJS, ensure your `package.json` does not have `"type": "module"` or use a transpiler like Babel.