From edc54bb38af2593c00d72fef7c466c2e847aa322 Mon Sep 17 00:00:00 2001 From: DevAndromeda <46562212+DevAndromeda@users.noreply.github.com> Date: Mon, 23 Aug 2021 18:25:25 +0545 Subject: [PATCH] fix(Player): check connection before setting channel --- example/music-bot/index.js | 4 +++- src/Player.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/example/music-bot/index.js b/example/music-bot/index.js index 3db8c3f..b707114 100644 --- a/example/music-bot/index.js +++ b/example/music-bot/index.js @@ -1,4 +1,6 @@ -require("dotenv").config(); +require("dotenv").config({ + path: __dirname+"/.env" +}); const { Client, GuildMember, Intents } = require("discord.js"); const config = require("./config"); const { Player, QueryType, QueueRepeatMode } = require("discord-player"); diff --git a/src/Player.ts b/src/Player.ts index 95ee756..2e3bbfc 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -77,7 +77,7 @@ class Player extends EventEmitter { if (!queue) return; if (oldState.channelId && newState.channelId && oldState.channelId !== newState.channelId) { - queue.connection.channel = newState.channel; + if (queue?.connection) queue.connection.channel = newState.channel; } if (!oldState.channelId && newState.channelId && newState.member.id === newState.guild.me.id) {