Discord Player
Getting started

Manual setup

Add Discord Player to an existing discord.js bot, step by step.

You are reading the v8 docsDev

This tutorial adds Discord Player to a discord.js bot you already have, or builds a small one from scratch. It plays direct links to MP3, Ogg, and WAV files and adds pause, skip, and queue commands. Discord Player itself does not depend on discord.js.

Starting a new bot? Generate one instead. The generator does everything on this page and also restricts which hosts /play can load.

Before you start

You need:

Install the packages

mkdir music-bot && cd music-bot
pnpm init
pnpm add discord-player@dev discord.js @remedia/node

Add "type": "module" to package.json. Node.js 22.18 and newer runs .ts files directly, so no build step is needed.

Use the dev tag while v8 is a preview

pnpm add discord-player installs v7, because npm's latest tag still points to it. @remedia/node must be the exact version that discord-player depends on. The generator always chooses a matching pair.

Create a .env file with your bot token:

.env
DISCORD_TOKEN=your-bot-token

What you will build

StepFilePurpose
1. Create the playersrc/player.tsConnect the Discord gateway to Discord Player
2. Add a sourcesrc/direct-media.tsTurn a URL into a playable track
3. Play a tracksrc/index.ts, src/commands.tsRegister /play and start the bot
4. Control playbacksrc/commands.tsAdd pause, resume, skip, stop, and queue

Continue reading

1. Create the player

On this page