From 260d5d2d73edb91e0ace0efd2e9f21b628f34b58 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 15 Mar 2020 15:04:46 -0500 Subject: [PATCH] Don't try to connect to channel if already connected --- src/commands/play.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commands/play.ts b/src/commands/play.ts index 84703da..03992d7 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -10,6 +10,7 @@ import {parse, toSeconds} from 'iso8601-duration'; import {TYPES} from '../types'; import {inject, injectable} from 'inversify'; import {QueuedSong, QueuedPlaylist} from '../services/queue'; +import {STATUS} from '../services/player'; import QueueManager from '../managers/queue'; import PlayerManager from '../managers/player'; import {getMostPopularVoiceChannel} from '../utils/channels'; @@ -214,11 +215,12 @@ export default class implements Command { // TODO: better response await res.stop('song(s) queued'); - const channel = getMostPopularVoiceChannel(msg.guild!); + if (this.playerManager.get(msg.guild!.id).status === STATUS.DISCONNECTED) { + const channel = getMostPopularVoiceChannel(msg.guild!); - // TODO: don't connect if already connected. - await this.playerManager.get(msg.guild!.id).connect(channel); + await this.playerManager.get(msg.guild!.id).connect(channel); - await this.playerManager.get(msg.guild!.id).play(); + await this.playerManager.get(msg.guild!.id).play(); + } } }