Skip to content

Commit

Permalink
fix(Player): check connection before setting channel
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Aug 23, 2021
1 parent 2344265 commit edc54bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion example/music-bot/index.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Player extends EventEmitter<PlayerEvents> {
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) {
Expand Down

0 comments on commit edc54bb

Please sign in to comment.