www.npmjs.com
Open in
urlscan Pro
2606:4700::6811:dfaf
Public Scan
URL:
https://www.npmjs.com/package/discord-player
Submission: On October 08 via api from US — Scanned from CA
Submission: On October 08 via api from US — Scanned from CA
Form analysis
1 forms found in the DOMGET /search
<form id="search" method="GET" action="/search" class="_13c93d41 relative flex bg-transparent ph3 ph2 pv2 ph0-ns pv0-ns bt b--black-10 bn-ns">
<div class="e82b10fd relative dde91b96">
<div class="_2f299eeb nowrap flex"><span class="_705cdf4f db fl pl3 pr1"><svg width="15px" height="15px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" aria-hidden="true">
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g stroke="#777777" stroke-width="1.3">
<g>
<path d="M13.4044,7.0274 C13.4044,10.5494 10.5494,13.4044 7.0274,13.4044 C3.5054,13.4044 0.6504,10.5494 0.6504,7.0274 C0.6504,3.5054 3.5054,0.6504 7.0274,0.6504 C10.5494,0.6504 13.4044,3.5054 13.4044,7.0274 Z"></path>
<path d="M11.4913,11.4913 L17.8683,17.8683"></path>
</g>
</g>
</g>
</svg></span><input type="search" role="combobox" name="q" hotkeys="[object Object]" placeholder="Search packages" aria-label="Search packages" aria-controls="typeahead-list-5985" aria-expanded="false" aria-activedescendant=""
inputref="[object Object]" autocomplete="off" class="_390acbc5 f5 fw3 black relative" value="" element="input"></div>
</div><button type="submit" class="_0da775bb bn pv2 ph4 f6 white pointer bn pv2 ph4 f6 white pointer" aria-label="Search">Search</button><input type="hidden" name="csrftoken" value="8YhcL4nAww5ADg2VRu-oyv4o6B90T8VZdN90Pu_Y5z3">
</form>
Text Content
skip to:contentpackage searchsign in ❤ * Pro * Teams * Pricing * Documentation npm Search Sign UpSign In DISCORD-PLAYER 6.7.1 • Public • Published 2 months ago * Readme * Code Beta * 6 Dependencies * 22 Dependents * 357 Versions DISCORD PLAYER Discord Player is a robust framework for developing Discord Music bots using JavaScript and TypeScript. It is built on top of the discord-voip library and offers a comprehensive set of customizable tools, making it one of the most feature enrich framework in town. WHY CHOOSE DISCORD PLAYER? * Beginner-friendly with easy-to-understand features * TypeScript support * Offers hackable APIs. * Supports audio player sharing * Quick and easy setup process * Wide range of player management features * Offers 64+ built-in audio filter presets * Highly customizable according to your needs * Automatic queue management * Query caching support * Extensible sources through the Extractors API * Object-oriented design * Built-in stats tracker * Offers easy debugging methods * Out-of-the-box voice states handling * IP Rotation support * Easy serialization and deserialization INSTALLATION BEFORE YOU START Discord Player requires Discord.js 14.0 or higher. Please ensure that you have a compatible version by running npm list discord.js in your terminal. If you're using an earlier version, please update it. The discord.js Guide provides resources to assist you with the update process. MAIN LIBRARY $ npm install --save discord-player # main library $ npm install --save @discord-player/extractor # extractors provider > Discord Player recognizes @discord-player/extractor and loads it automatically > by default. Just invoke await player.extractors.loadDefault(). OPUS LIBRARY Since Discord only accepts opus packets, you need to install the opus library. Discord Player supports multiple opus libraries, such as: * mediaplex * @discordjs/opus * opusscript * @evan/opus * node-opus Among these, mediaplex is the recommended library as it adds more functionalities to discord-player than just libopus interface. You can install opus libraries by running: $ npm install --save mediaplex # or $ npm install --save @discordjs/opus # or $ npm install --save opusscript # or $ npm install --save @evan/opus # or $ npm install --save node-opus FFMPEG OR AVCONV FFmpeg or Avconv is required for media transcoding. You can obtain it from https://ffmpeg.org or via npm. > We do not recommend installing ffmpeg via npm because binaries pulled from npm > is known to be unstable. It is recommended to install it from the official > source. $ 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 > Use FFMPEG_PATH environment variable to load ffmpeg from custom path. STREAMING LIBRARY The following method is deprecated and will be removed in the future. Please switch to discord-player-youtubei. Not recommended: YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source. $ npm install --save youtube-ext # or $ npm install --save play-dl # or $ npm install --save @distube/ytdl-core # or $ npm install --save yt-stream # or $ npm install --save ytdl-core Once you have completed these installations, let's proceed with writing a simple music bot. SETUP Let's create a main player instance. This instance handles and keeps track of all the queues and its components. const { Player } = require('discord-player'); 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, except 'YouTubeExtractor'. You can remove the filter if you want to include youtube. await player.extractors.loadDefault((ext) => ext !== 'YouTubeExtractor'); Discord Player is mostly events based. It emits different events based on the context and actions. Let's add a basic event listener to notify the user when a track starts to play: // 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}**!`); }); Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command part: const { useMainPlayer } = require('discord-player'); export async function execute(interaction) { const player = useMainPlayer(); const channel = interaction.member.voice.channel; if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel const query = interaction.options.getString('query', true); // we need input/query to play // let's defer the interaction as things can take time to process await interaction.deferReply(); try { const { track } = await player.play(channel, query, { nodeOptions: { // nodeOptions are the options for guild node (aka your queue in simple word) metadata: interaction // we can access this metadata object using queue.metadata later on } }); return interaction.followUp(`**${track.cleanTitle}** enqueued!`); } catch (e) { // let's return error if something failed return interaction.followUp(`Something went wrong: ${e}`); } } That's all it takes to build your own music bot. Please check out the Documentation for more features/functionalities. COMMUNITY RESOURCES Explore a curated list of resources built by the Discord Player community, including open-source music bots and extractors. Visit https://discord-player.js.org/showcase for more information. README KEYWORDS * music * player * bot * framework * discord * volume * queue * youtube * discord.js * musicbot * discord-music-player * discord-music * music-player * youtube-dl * ytdl-core * ytdl * lavalink * api PACKAGE SIDEBAR INSTALL npm i discord-player REPOSITORY Gitgithub.com/Androz2091/discord-player HOMEPAGE discord-player.js.org Fund this package DOWNLOADSWEEKLY DOWNLOADS 4,119 VERSION 6.7.1 LICENSE MIT UNPACKED SIZE 814 kB TOTAL FILES 6 ISSUES 2 PULL REQUESTS 2 LAST PUBLISH 4 days ago COLLABORATORS * * Try on RunKit Report malware FOOTER SUPPORT * Help * Advisories * Status * Contact npm COMPANY * About * Blog * Press TERMS & POLICIES * Policies * Terms of Use * Code of Conduct * Privacy