From 5975e52651d1c2a9f4b5a10094c8dcce102cb8ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Aug 2021 04:32:14 +0000 Subject: [PATCH 01/10] chore(deps): bump @discordjs/voice from 0.5.5 to 0.5.6 Bumps [@discordjs/voice](https://github.com/discordjs/voice) from 0.5.5 to 0.5.6. - [Release notes](https://github.com/discordjs/voice/releases) - [Commits](https://github.com/discordjs/voice/compare/v0.5.5...v0.5.6) --- updated-dependencies: - dependency-name: "@discordjs/voice" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- yarn.lock | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2419a4f..7a2af5a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -984,12 +984,12 @@ node-addon-api "^3.2.1" "@discordjs/voice@^0.5.5": - version "0.5.5" - resolved "https://registry.yarnpkg.com/@discordjs/voice/-/voice-0.5.5.tgz#25dfe4709e5da103875f212f40cf63068abd8850" - integrity sha512-i7QSRlPq34UAoTUfxLjlyWJONdrxJ4kZH7F6ZfoDK1rt3AHZv5vFzijBu8bsy040zaYpU3LZQ2MPw/kz1uCr5w== + version "0.5.6" + resolved "https://registry.yarnpkg.com/@discordjs/voice/-/voice-0.5.6.tgz#78d52567acacab28411fca1dbf8fe3f7b6cc86d3" + integrity sha512-CGwD5pz1YB8MXfERcXQ6jVCThfMjzPKbad8pYuvPt4ozFcLWGRKFJ5lj+CSRNDj0Cobc6MIKOKpFfOPlXTKTrw== dependencies: "@types/ws" "^7.4.4" - discord-api-types "^0.19.0" + discord-api-types "^0.22.0" prism-media "^1.3.1" tiny-typed-emitter "^2.0.3" ws "^7.4.4" @@ -2042,11 +2042,6 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -discord-api-types@^0.19.0: - version "0.19.0" - resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.19.0.tgz#86ba8021b29190cf860e90a2bc3e29b1d7aab3ba" - integrity sha512-t2HKLd43Lbe+rf+ffYfKVv9Kk5f6p7sFqvO6CMV55ZB0PgZv8WigCkt9FoJciYo5S3Q6CGYK+WnE/ZG+6vkBDQ== - discord-api-types@^0.22.0: version "0.22.0" resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.22.0.tgz#34dc57fe8e016e5eaac5e393646cd42a7e1ccc2a" From 66ae840e227dde2367e45a3f11ac5ad150873433 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Aug 2021 04:32:46 +0000 Subject: [PATCH 02/10] chore(deps-dev): bump ts-node from 10.1.0 to 10.2.0 Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.1.0 to 10.2.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.1.0...v10.2.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- yarn.lock | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2419a4f..ecbabba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -916,6 +916,18 @@ "@babel/helper-validator-identifier" "^7.14.9" to-fast-properties "^2.0.0" +"@cspotcode/source-map-consumer@0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" + integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== + +"@cspotcode/source-map-support@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz#118511f316e2e87ee4294761868e254d3da47960" + integrity sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg== + dependencies: + "@cspotcode/source-map-consumer" "0.8.0" + "@devsnowflake/docgen@devsnowflake/docgen#ts-patch": version "0.9.0" resolved "https://codeload.github.com/devsnowflake/docgen/tar.gz/cc87c4dfa7136fa1046946eff708bb995ca5e1f7" @@ -1102,7 +1114,7 @@ resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== -"@tsconfig/node16@^1.0.1": +"@tsconfig/node16@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== @@ -1221,12 +1233,17 @@ acorn-walk@^7.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== +acorn-walk@^8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.1.1.tgz#3ddab7f84e4a7e2313f6c414c5b7dac85f4e3ebc" + integrity sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w== + acorn@^7.1.1, acorn@^7.4.0: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.2.4: +acorn@^8.2.4, acorn@^8.4.1: version "8.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== @@ -1567,11 +1584,6 @@ browserslist@^4.16.6: escalade "^3.1.1" node-releases "^1.1.73" -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - cache-base@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" @@ -4357,14 +4369,6 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.17: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - source-map-url@^0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" @@ -4375,7 +4379,7 @@ source-map@^0.5.0, source-map@^0.5.6: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: +source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -4685,19 +4689,21 @@ ts-mixer@^6.0.0: integrity sha512-nXIb1fvdY5CBSrDIblLn73NW0qRDk5yJ0Sk1qPBF560OdJfQp9jhl+0tzcY09OZ9U+6GpeoI9RjwoIKFIoB9MQ== ts-node@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.1.0.tgz#e656d8ad3b61106938a867f69c39a8ba6efc966e" - integrity sha512-6szn3+J9WyG2hE+5W8e0ruZrzyk1uFLYye6IGMBadnOzDh8aP7t8CbFpsfCiEx2+wMixAhjFt7lOZC4+l+WbEA== + version "10.2.0" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.2.0.tgz#f1e88249a00e26aa95e9a93c50f70241a8a1c4bb" + integrity sha512-FstYHtQz6isj8rBtYMN4bZdnXN1vq4HCbqn9vdNQcInRqtB86PePJQIxE6es0PhxKWhj2PHuwbG40H+bxkZPmg== dependencies: + "@cspotcode/source-map-support" "0.6.1" "@tsconfig/node10" "^1.0.7" "@tsconfig/node12" "^1.0.7" "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.1" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" arg "^4.1.0" create-require "^1.1.0" diff "^4.0.1" make-error "^1.1.1" - source-map-support "^0.5.17" yn "3.1.1" tslib@^1.8.1, tslib@^1.9.0: From 3c39020e2ac6eb730371a31fc61bdc5ad09e4a93 Mon Sep 17 00:00:00 2001 From: Maxim Coppieters <58440941+MaxTechnics@users.noreply.github.com> Date: Mon, 9 Aug 2021 14:47:06 +0200 Subject: [PATCH 03/10] Add JSDoc for trackEnd event --- src/types/types.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/types.ts b/src/types/types.ts index e04f76c..4b7f807 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -307,6 +307,13 @@ export enum QueryType { * @param {Track} track The track */ +/** + * Emitted when a track ends + * @event Player#trackEnd + * @param {Queue} queue The queue + * @param {Track} track The track + */ + /* eslint-disable @typescript-eslint/no-explicit-any */ export interface PlayerEvents { botDisconnect: (queue: Queue) => any; From 5780e6e6f4ba54c26392dea8d429873a546f12b8 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 9 Aug 2021 18:43:18 +0545 Subject: [PATCH 04/10] fix(Player): add intents checking --- src/Player.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index 1058b8c..b7b81d4 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -1,4 +1,4 @@ -import { Client, Collection, GuildResolvable, Snowflake, User, VoiceState } from "discord.js"; +import { Client, Collection, GuildResolvable, Snowflake, User, VoiceState, Intents } from "discord.js"; import { TypedEmitter as EventEmitter } from "tiny-typed-emitter"; import { Queue } from "./Structures/Queue"; import { VoiceUtils } from "./VoiceInterface/VoiceUtils"; @@ -46,6 +46,10 @@ class Player extends EventEmitter { */ this.client = client; + if (new Intents(this.client.options.intents).has(Intents.FLAGS.GUILD_VOICE_STATES)) { + throw new PlayerError('client is missing "GUILD_VOICE_STATES" intent'); + } + /** * The extractors collection * @type {ExtractorModel} From 615c3ad82f8d25695e8bdfdda980821375175532 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 9 Aug 2021 18:49:35 +0545 Subject: [PATCH 05/10] fix(Player): add intents checking --- src/Player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index b7b81d4..6f01038 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -46,7 +46,7 @@ class Player extends EventEmitter { */ this.client = client; - if (new Intents(this.client.options.intents).has(Intents.FLAGS.GUILD_VOICE_STATES)) { + if (!(new Intents(this.client.options.intents).has(Intents.FLAGS.GUILD_VOICE_STATES))) { throw new PlayerError('client is missing "GUILD_VOICE_STATES" intent'); } From c11609795445953174a3077afd05b5882eed4953 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 9 Aug 2021 18:49:58 +0545 Subject: [PATCH 06/10] fix(Player): add intents checking --- src/Player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Player.ts b/src/Player.ts index 6f01038..a6cd5d0 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -46,7 +46,7 @@ class Player extends EventEmitter { */ this.client = client; - if (!(new Intents(this.client.options.intents).has(Intents.FLAGS.GUILD_VOICE_STATES))) { + if (!new Intents(this.client.options.intents).has(Intents.FLAGS.GUILD_VOICE_STATES)) { throw new PlayerError('client is missing "GUILD_VOICE_STATES" intent'); } From 00ebee738247088985530967d7b7b27e88507a19 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 9 Aug 2021 18:50:46 +0545 Subject: [PATCH 07/10] chore(example): bump discord-player --- example/music-bot/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/music-bot/package.json b/example/music-bot/package.json index 76141e0..a722305 100644 --- a/example/music-bot/package.json +++ b/example/music-bot/package.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@discordjs/opus": "^0.5.3", - "discord-player": "^5.0.0", + "discord-player": "^5.0.1", "discord.js": "^13.0.1", "dotenv": "^10.0.0" } From e7c377ed0cabc92ce03583e27acc19bd5d31db35 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 9 Aug 2021 19:56:23 +0545 Subject: [PATCH 08/10] feat(example): add /ping command --- example/music-bot/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/example/music-bot/index.js b/example/music-bot/index.js index ce15ada..30d6d74 100644 --- a/example/music-bot/index.js +++ b/example/music-bot/index.js @@ -145,6 +145,10 @@ client.on("messageCreate", async (message) => { { name: "bassboost", description: "Toggles bassboost filter" + }, + { + name: "ping", + description: "Shows bot latency" } ]); @@ -155,6 +159,24 @@ client.on("messageCreate", async (message) => { client.on("interactionCreate", async (interaction) => { if (!interaction.isCommand() || !interaction.guildId) return; + if (interaction.commandName === "ping") { + await interaction.deferReply(); + const queue = player.getQueue(interaction.guild); + + return void interaction.followUp({ + embeds: [ + { + title: "⏱️ | Latency", + fields: [ + { name: "Bot Latency", value: `\`${Math.round(client.ws.ping)}ms\`` }, + { name: "Voice Latency", value: !queue ? "N/A" : `UDP: \`${queue.connection.voiceConnection.ping.udp ?? "N/A"}\`ms\nWebSocket: \`${queue.connection.voiceConnection.ping.ws ?? "N/A"}\`ms` } + ], + color: 0xFFFFFF + } + ] + }); + } + if (!(interaction.member instanceof GuildMember) || !interaction.member.voice.channel) { return void interaction.reply({ content: "You are not in a voice channel!", ephemeral: true }); } From f633a7c0ddf56c71db46c115c0e0ce92752b31a6 Mon Sep 17 00:00:00 2001 From: Maxim Coppieters <58440941+MaxTechnics@users.noreply.github.com> Date: Mon, 9 Aug 2021 16:56:40 +0200 Subject: [PATCH 09/10] Fix minor typos --- CONTRIBUTING.md | 2 +- docs/migrating/migrating.md | 2 +- src/Player.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd2bd5e..e0cd9db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ We are using **[Prettier](https://prettier.io)** to format the code. ## Some Rules - Use `camelCase` for `Function names`, `Variables`, etc. and `PascalCase` for `Class name` - Do not make unused variables/imports -- Don't forget to write `JSDOC` for each properties and methods +- Don't forget to write `JSDOC` for each property and method - Use English language # Pull Requests diff --git a/docs/migrating/migrating.md b/docs/migrating/migrating.md index 9860d13..b57b084 100644 --- a/docs/migrating/migrating.md +++ b/docs/migrating/migrating.md @@ -35,7 +35,7 @@ const queue = player.createQueue(message.guild, { }); ``` -The metadata `message` will always be available in every events emitted for that specific `Queue`. You can access it via `queue.metadata`: +The metadata `message` will always be available in every event emitted for that specific `Queue`. You can access it via `queue.metadata`: ```js player.on("trackStart", (queue, track) => { diff --git a/src/Player.ts b/src/Player.ts index 1058b8c..733ed09 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -512,7 +512,7 @@ class Player extends EventEmitter { } /** - * Resolves qeuue + * Resolves queue * @param {GuildResolvable|Queue} queueLike Queue like object * @returns {Queue} */ From 5f8ad43b55d06062408542d963eb0a0bd75deb20 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 9 Aug 2021 22:57:36 +0545 Subject: [PATCH 10/10] refactor(example): use intents provided by discord.js --- example/music-bot/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/music-bot/index.js b/example/music-bot/index.js index 30d6d74..99914ba 100644 --- a/example/music-bot/index.js +++ b/example/music-bot/index.js @@ -1,9 +1,9 @@ require("dotenv").config(); -const { Client, GuildMember } = require("discord.js"); +const { Client, GuildMember, Intents } = require("discord.js"); const config = require("./config"); const { Player, QueryType, QueueRepeatMode } = require("discord-player"); const client = new Client({ - intents: ["GUILD_VOICE_STATES", "GUILD_MESSAGES", "GUILDS"] + intents: [Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILDS] }); client.on("ready", () => {