This commit is contained in:
DevAndromeda 2021-08-08 01:15:20 +05:45
commit a276d48315
9 changed files with 17 additions and 15 deletions

View file

@ -16,19 +16,16 @@ on:
- '!gh-pages' - '!gh-pages'
jobs: jobs:
test: test:
strategy: name: ESLint (Node v16)
matrix:
node: ['14', '16']
name: ESLint (Node v${{ matrix.node }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install Node v${{ matrix.node }} - name: Install Node v16
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node }} node-version: 16
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install

View file

@ -52,3 +52,8 @@ You have to use `<Queue>.destroy()` to destroy the queue. It will also stop the
const queue = player.getQueue(message.guild.id); const queue = player.getQueue(message.guild.id);
if (queue) queue.destroy(); if (queue) queue.destroy();
``` ```
## Updating filters
Discord Player v5.x has new option `bufferingTimeout` in queue init options which allows you to set stream buffering timeout before playing.
This might be useful if you want to have smooth filters update. By default, it is set to 3 seconds.

View file

@ -215,7 +215,7 @@ client.on("interactionCreate", async (interaction) => {
if (!queue || !queue.playing) return void interaction.followUp({ content: "❌ | No music is being played!" }); if (!queue || !queue.playing) return void interaction.followUp({ content: "❌ | No music is being played!" });
const currentTrack = queue.current; const currentTrack = queue.current;
const tracks = queue.tracks.slice(0, 10).map((m, i) => { const tracks = queue.tracks.slice(0, 10).map((m, i) => {
return `${i + 1}. **${m.title}**`; return `${i + 1}. **${m.title}** ([link](${m.url}))`;
}); });
return void interaction.followUp({ return void interaction.followUp({
@ -228,7 +228,7 @@ client.on("interactionCreate", async (interaction) => {
: "" : ""
}`, }`,
color: 0xff0000, color: 0xff0000,
fields: [{ name: "Now Playing", value: `🎶 | **${currentTrack.title}**` }] fields: [{ name: "Now Playing", value: `🎶 | **${currentTrack.title}** ([link](${currentTrack.url}))` }]
} }
] ]
}); });

View file

@ -11,6 +11,6 @@
"dependencies": { "dependencies": {
"@discordjs/opus": "^0.5.3", "@discordjs/opus": "^0.5.3",
"discord-player": "^5.0.0-dev.39f503a.1625470163", "discord-player": "^5.0.0-dev.39f503a.1625470163",
"discord.js": "^13.0.0-dev.fe5d56c.1625443439" "discord.js": "^13.0.1"
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "discord-player", "name": "discord-player",
"version": "5.0.0-dev", "version": "5.0.0",
"description": "Complete framework to facilitate music commands using discord.js", "description": "Complete framework to facilitate music commands using discord.js",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View file

@ -117,7 +117,7 @@ class Player extends EventEmitter<PlayerEvents> {
if (!this.queues.has(queue.guild.id)) return; if (!this.queues.has(queue.guild.id)) return;
queue.destroy(); queue.destroy();
this.emit("channelEmpty", queue); this.emit("channelEmpty", queue);
}, queue.options.leaveOnEmptyCooldown || 0); }, queue.options.leaveOnEmptyCooldown || 0).unref();
queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout); queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
} }
} }

View file

@ -657,7 +657,7 @@ class Queue<T = unknown> {
this.connection.playStream(resource).then(() => { this.connection.playStream(resource).then(() => {
this.setVolume(this.options.initialVolume); this.setVolume(this.options.initialVolume);
}); });
}, this.#getBufferingTimeout()); }, this.#getBufferingTimeout()).unref();
} }
/** /**

View file

@ -91,7 +91,7 @@ class Util {
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
static wait(time: number) { static wait(time: number) {
return new Promise((r) => setTimeout(r, time)); return new Promise((r) => setTimeout(r, time).unref());
} }
static noop() {} // eslint-disable-line @typescript-eslint/no-empty-function static noop() {} // eslint-disable-line @typescript-eslint/no-empty-function