{"_id":"@andy1210/discord-player","_rev":"2-62f518c470649dc2af0fc1a2560ef646","name":"@andy1210/discord-player","dist-tags":{"latest":"5.1.0"},"versions":{"5.1.0":{"name":"@andy1210/discord-player","version":"5.1.0","description":"Complete framework to facilitate music commands using discord.js","main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{"require":"./dist/index.js","import":"./dist/index.mjs"},"scripts":{"dev":"cd example/test && ts-node index.ts","build":"rimraf dist && tsc && npm run build:esm","build:check":"tsc --noEmit --incremental false","prepublishOnly":"rollup-type-bundler -e stream","build:esm":"gen-esm-wrapper ./dist/index.js ./dist/index.mjs","format":"prettier --write \"src/**/*.ts\" \"example/**/*.ts\"","docs":"docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json","docs:test":"docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml","lint":"eslint src --ext .ts","prepare":"husky install","lint:fix":"eslint src --ext .ts --fix"},"funding":"https://github.com/Androz2091/discord-player?sponsor=1","contributors":[{"name":"DevAndromeda","email":"devandromeda@snowflakedev.org"}],"repository":{"type":"git","url":"git+https://github.com/Androz2091/discord-player.git"},"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"],"author":{"name":"Androz2091"},"license":"MIT","bugs":{"url":"https://github.com/Androz2091/discord-player/issues"},"homepage":"https://discord-player.js.org","dependencies":{"@discordjs/voice":"^0.6.0","discord-ytdl-core":"^5.0.4","libsodium-wrappers":"^0.7.9","soundcloud-scraper":"^5.0.2","spotify-url-info":"^2.2.3","tiny-typed-emitter":"^2.1.0","youtube-sr":"^4.1.7","ytdl-core":"^4.9.1"},"devDependencies":{"@babel/cli":"^7.15.7","@babel/core":"^7.15.5","@babel/preset-env":"^7.15.6","@babel/preset-typescript":"^7.15.0","@devsnowflake/docgen":"github:devsnowflake/docgen#ts-patch","@discord-player/extractor":"^3.0.2","@discordjs/opus":"github:discordjs/opus","@favware/rollup-type-bundler":"^1.0.3","@types/node":"^16.9.6","@types/ws":"^8.2.0","@typescript-eslint/eslint-plugin":"^4.31.2","@typescript-eslint/parser":"^4.31.2","discord-api-types":"^0.23.1","discord.js":"^13.1.0","eslint":"^7.32.0","gen-esm-wrapper":"^1.1.3","husky":"^7.0.2","jsdoc-babel":"^0.5.0","prettier":"^2.4.1","rimraf":"^3.0.2","ts-node":"^10.2.1","typescript":"^4.4.3"},"gitHead":"7c876cc18e3713fdbdf99895453f12a3b74b9f32","_id":"@andy1210/discord-player@5.1.0","_nodeVersion":"16.10.0","_npmVersion":"7.24.0","dist":{"integrity":"sha512-e4r94pZDqe638U6wLz2TYMJLPN7/qMWtjkicoSm9em/wAOIArHVO8OLFKIzQ9IX6xQYYBFl/246oT3OXi8Cxug==","shasum":"6cc8234bb66a7cde75d5d7b06868de7602282869","tarball":"https://registry.npmjs.org/@andy1210/discord-player/-/discord-player-5.1.0.tgz","fileCount":18,"unpackedSize":154571,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhwyItCRA9TVsSAnZWagAAjaIP+wd/kdnEuOwVxmM8ISeI\n6qjBrv1XbwhB6fM9iGhetuyXEu7nr8H+a+Sfr5w4Yny4fA38lxoinOAM7jsq\nLSl41ivmm89SinU/iZYFAbhBXVaMRfNzY4RbfxAcoGNRp4DTbJRjg9LnQvZc\nUyiIv2NurzO2PT5t226omztOLBeBpQVfsdUrJFJTE8IGsR9Mb/gkZ7W35OiQ\nZ/0riU9pW/a6ziAazUy7sDH7RkO2d+AmYscoAyEPP40rC/ODRObkw1XTsJGj\nT0c5biXFwO2euIWpUiNRyhMXJ3UGEXAYskgUOvL7meaRkQKQWmakKKD4zcZZ\nDpctmwWnLy6c6Y1z6A1drjUw8NAhSBht8wuB3oNIWYzHQ9fzGNYf30kqEhz+\n9yIFQnUP87mlPxSPKn74LhRZB6SQ0NVO9p5xDGdorxGbljF45r6FZADlzlZO\njUEypU0INQXvwExgf9xKfgEEIoqV4qOhboaM9dGyaoE1iqNENa9DoepQYRIF\neMAsfwxQsu/wnE9rKiU7EgVSzWruyzjSvDlrvkDQ2/tCl79+XnQUc7v52j1X\nauY0hW4h5tqpMfKdHm0UHTle+MWMfFgyzMwox69suzr/yQEE8uGYKcJey3JM\njL6ylHxpopZxUfpUf1m9mKP189rdNUTTmhB/BoeIfCQgVU1Cs+sxPpcmIQ9B\nYfVj\r\n=3Z84\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDdffv/pOFiydTlScenKfYeS7FZzlgZkAb0PUgHwJ9GCAiAopriWpFh0Og2J5Pd6UwTBRC67HvVAUg8xj6vlvAP5pg=="}]},"_npmUser":{"name":"andy1210","email":"andy1210@gmail.com"},"directories":{},"maintainers":[{"name":"andy1210","email":"andy1210@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/discord-player_5.1.0_1634318303480_0.7550510472651955"},"_hasShrinkwrap":false}},"time":{"created":"2021-10-15T17:18:23.421Z","5.1.0":"2021-10-15T17:18:23.642Z","modified":"2022-04-04T14:04:31.355Z"},"maintainers":[{"name":"andy1210","email":"andy1210@gmail.com"}],"description":"Complete framework to facilitate music commands using discord.js","homepage":"https://discord-player.js.org","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"],"repository":{"type":"git","url":"git+https://github.com/Androz2091/discord-player.git"},"contributors":[{"name":"DevAndromeda","email":"devandromeda@snowflakedev.org"}],"author":{"name":"Androz2091"},"bugs":{"url":"https://github.com/Androz2091/discord-player/issues"},"license":"MIT","readme":"# Discord Player\nComplete framework to facilitate music commands using **[discord.js](https://discord.js.org)**.\n\n[![downloadsBadge](https://img.shields.io/npm/dt/discord-player?style=for-the-badge)](https://npmjs.com/discord-player)\n[![versionBadge](https://img.shields.io/npm/v/discord-player?style=for-the-badge)](https://npmjs.com/discord-player)\n[![discordBadge](https://img.shields.io/discord/558328638911545423?style=for-the-badge&color=7289da)](https://androz2091.fr/discord)\n[![wakatime](https://wakatime.com/badge/github/Androz2091/discord-player.svg)](https://wakatime.com/badge/github/Androz2091/discord-player)\n[![CodeFactor](https://www.codefactor.io/repository/github/androz2091/discord-player/badge/v5)](https://www.codefactor.io/repository/github/androz2091/discord-player/overview/v5)\n\n## Installation\n\n### Install **[discord-player](https://npmjs.com/package/discord-player)**\n\n```sh\n$ npm install --save discord-player\n```\n\n### Install **[@discordjs/opus](https://npmjs.com/package/@discordjs/opus)**\n\n```sh\n$ npm install --save @discordjs/opus\n```\n\n### Install FFmpeg or Avconv\n- Official FFMPEG Website: **[https://www.ffmpeg.org/download.html](https://www.ffmpeg.org/download.html)**\n\n- Node Module (FFMPEG): **[https://npmjs.com/package/ffmpeg-static](https://npmjs.com/package/ffmpeg-static)**\n\n- Avconv: **[https://libav.org/download](https://libav.org/download)**\n\n# Features\n- Simple & easy to use 🤘\n- Beginner friendly 😱\n- Audio filters 🎸\n- Lightweight 🛬\n- Custom extractors support 🌌\n- Lyrics 📃\n- Multiple sources support ✌\n- Play in multiple servers at the same time 🚗\n\n## [Documentation](https://discord-player.js.org)\n\n## Getting Started\n\nFirst of all, you will need to register slash commands:\n\n```js\nconst { REST } = require(\"@discordjs/rest\");\nconst { Routes } = require(\"discord-api-types/v9\");\n\nconst commands = [{\n    name: \"play\",\n    description: \"Plays a song!\",\n    options: [\n        {\n            name: \"query\",\n            type: \"STRING\",\n            description: \"The song you want to play\",\n            required: true\n        }\n    ]\n}]; \n\nconst rest = new REST({ version: \"9\" }).setToken(process.env.DISCORD_TOKEN);\n\n(async () => {\n  try {\n    console.log(\"Started refreshing application [/] commands.\");\n\n    await rest.put(\n      Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),\n      { body: commands },\n    );\n\n    console.log(\"Successfully reloaded application [/] commands.\");\n  } catch (error) {\n    console.error(error);\n  }\n})();\n```\n\nNow you can implement your bot's logic:\n\n```js\nconst { Client, Intents } = require(\"discord.js\");\nconst client = new Discord.Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES] });\nconst { Player } = require(\"discord-player\");\n\n// Create a new Player (you don't need any API Key)\nconst player = new Player(client);\n\n// add the trackStart event so when a song will be played this message will be sent\nplayer.on(\"trackStart\", (queue, track) => queue.metadata.channel.send(`🎶 | Now playing **${track.title}**!`))\n\nclient.once(\"ready\", () => {\n    console.log(\"I'm ready !\");\n});\n\nclient.on(\"interactionCreate\", async (interaction) => {\n    if (!interaction.isCommand()) return;\n\n    // /play Despacito\n    // will play \"Despacito\" in the voice channel\n    if (interaction.commandName === \"play\") {\n        if (!interaction.member.voice.channelId) return await interaction.reply({ content: \"You are not in a voice channel!\", ephemeral: true });\n        if (interaction.guild.me.voice.channelId && interaction.member.voice.channelId !== interaction.guild.me.voice.channelId) return await interaction.reply({ content: \"You are not in my voice channel!\", ephemeral: true });\n        const query = interaction.options.get(\"query\").value;\n        const queue = player.createQueue(interaction.guild, {\n            metadata: {\n                channel: interaction.channel\n            }\n        });\n        \n        // verify vc connection\n        try {\n            if (!queue.connection) await queue.connect(interaction.member.voice.channel);\n        } catch {\n            queue.destroy();\n            return await interaction.reply({ content: \"Could not join your voice channel!\", ephemeral: true });\n        }\n\n        await interaction.deferReply();\n        const track = await player.search(query, {\n            requestedBy: interaction.user\n        }).then(x => x.tracks[0]);\n        if (!track) return await interaction.followUp({ content: `❌ | Track **${query}** not found!` });\n\n        queue.play(track);\n\n        return await interaction.followUp({ content: `⏱️ | Loading track **${track.title}**!` });\n    }\n});\n\nclient.login(process.env.DISCORD_TOKEN);\n```\n\n## Supported websites\n\nBy default, discord-player supports **YouTube**, **Spotify** and **SoundCloud** streams only.\n\n### Optional dependencies\n\nDiscord Player provides an **Extractor API** that enables you to use your custom stream extractor with it. Some packages have been made by the community to add new features using this API.\n\n#### [@discord-player/extractor](https://github.com/Snowflake107/discord-player-extractors) (optional)\n\nOptional package that adds support for `vimeo`, `reverbnation`, `facebook`, `attachment links` and `lyrics`.\nYou just need to install it using `npm i --save @discord-player/extractor` (discord-player will automatically detect and use it).\n\n#### [@discord-player/downloader](https://github.com/DevSnowflake/discord-player-downloader) (optional)\n\n`@discord-player/downloader` is an optional package that brings support for +700 websites. The documentation is available [here](https://github.com/DevSnowflake/discord-player-downloader).\n\n## Examples of bots made with Discord Player\n\nThese bots are made by the community, they can help you build your own!\n\n* **[Discord Music Bot](https://github.com/Androz2091/discord-music-bot)** by [Androz2091](https://github.com/Androz2091)\n* [AtlantaBot](https://github.com/Androz2091/AtlantaBot) by [Androz2091](https://github.com/Androz2091) (**outdated**)\n* [Discord-Music](https://github.com/inhydrox/discord-music) by [inhydrox](https://github.com/inhydrox) (**outdated**)\n* [Music-bot](https://github.com/ZerioDev/Music-bot) by [ZerioDev](https://github.com/ZerioDev) (**outdated**)\n\n## Advanced\n\n### Use cookies\n\n```js\nconst player = new Player(client, {\n    ytdlOptions: {\n        requestOptions: {\n            headers: {\n                cookie: \"YOUR_YOUTUBE_COOKIE\"\n            }\n        }\n    }\n});\n```\n\n### Use custom proxies\n\n```js\nconst HttpsProxyAgent = require(\"https-proxy-agent\");\n\n// Remove \"user:pass@\" if you don't need to authenticate to your proxy.\nconst proxy = \"http://user:pass@111.111.111.111:8080\";\nconst agent = HttpsProxyAgent(proxy);\n\nconst player = new Player(client, {\n    ytdlOptions: {\n        requestOptions: { agent }\n    }\n});\n```\n\n### Custom stream Engine\n\nDiscord Player by default uses **[node-ytdl-core](https://github.com/fent/node-ytdl-core)** for youtube and some other extractors for other sources.\nIf you need to modify this behavior without touching extractors, you need to use `createStream` functionality of discord player.\nHere's an example on how you can use **[play-dl](https://npmjs.com/package/play-dl)** to download youtube streams instead of using ytdl-core.\n\n```js\nconst playdl = require(\"play-dl\");\n\n// other code\nconst queue = player.createQueue(..., {\n    ...,\n    async onBeforeCreateStream(track, source, _queue) {\n        // only trap youtube source\n        if (source === \"youtube\") {\n            // track here would be youtube track\n            return (await playdl.stream(track.url)).stream;\n            // we must return readable stream or void (returning void means telling discord-player to look for default extractor)\n        }\n    }\n});\n```\n\n`<Queue>.onBeforeCreateStream` is called before actually downloading the stream. It is a different concept from extractors, where you are **just** downloading\nstreams. `source` here will be a video source. Streams from `onBeforeCreateStream` are then piped to `FFmpeg` and finally sent to Discord voice servers.","readmeFilename":"README.md"}