docs
This commit is contained in:
parent
9f69ddab60
commit
8e2f50cfb5
2 changed files with 58 additions and 0 deletions
|
@ -2,6 +2,10 @@
|
||||||
files:
|
files:
|
||||||
- name: Welcome
|
- name: Welcome
|
||||||
path: welcome.md
|
path: welcome.md
|
||||||
|
- name: Migrating
|
||||||
|
files:
|
||||||
|
- name: Migrating to v5
|
||||||
|
path: migrating.md
|
||||||
- name: Extractors
|
- name: Extractors
|
||||||
files:
|
files:
|
||||||
- name: Extractors API
|
- name: Extractors API
|
||||||
|
@ -10,6 +14,8 @@
|
||||||
files:
|
files:
|
||||||
- name: Custom Filters
|
- name: Custom Filters
|
||||||
path: custom_filters.md
|
path: custom_filters.md
|
||||||
|
- name: Slash Commands
|
||||||
|
path: slash_commands.md
|
||||||
- name: YouTube
|
- name: YouTube
|
||||||
files:
|
files:
|
||||||
- name: Using Cookies
|
- name: Using Cookies
|
||||||
|
|
52
docs/migrating/migrating.md
Normal file
52
docs/migrating/migrating.md
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Migrating to Discord Player v5
|
||||||
|
|
||||||
|
We have introduced some breaking changes in Discord Player v5. Which means, your old code will no longer work with v5.
|
||||||
|
The new update brings new features as well as better management of different things. This also uses the new **[@discordjs/voice](https://github.com/discordjs/voice)** library!
|
||||||
|
|
||||||
|
## Basic Example
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- player.play(message, query);
|
||||||
|
+ const queue = player.createQueue(message.guild);
|
||||||
|
+ const song = await player.search(query);
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ await queue.connect(message.member.voice.channel);
|
||||||
|
+ } catch {
|
||||||
|
+ message.reply("Could not join your voice channel");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ queue.addTrack(song.tracks[0]);
|
||||||
|
+ queue.play();
|
||||||
|
```
|
||||||
|
|
||||||
|
> Everything related to music player is moved to `Queue`.
|
||||||
|
|
||||||
|
## How do I reply to the event like v4?
|
||||||
|
|
||||||
|
Since we got rid of `message` parameter in every method of the Discord Player, you no longer have access to the `message` object in events.
|
||||||
|
Instead, we have added `<Queue>.metadata` prop as an alternative. This `metadata` can be anything, declared while creating queue:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const queue = player.createQueue(message.guild, {
|
||||||
|
metadata: message
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
The metadata `message` will always be available in every events emitted for that specific `Queue`. You can access it via `queue.metadata`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
player.on("trackStart", (queue, track) => {
|
||||||
|
const channel = queue.metadata.channel; // queue.metadata is your "message" object
|
||||||
|
channel.send(`🎶 | Started playing **${track.title}**`);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## How do I stop the player
|
||||||
|
|
||||||
|
You have to use `<Queue>.destroy()` to destroy the queue. It will also stop the player.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const queue = player.getQueue(message.guild.id);
|
||||||
|
if (queue) queue.destroy();
|
||||||
|
```
|
Loading…
Reference in a new issue