Don't try to connect to channel if already connected

This commit is contained in:
Max Isom 2020-03-15 15:04:46 -05:00
parent 3408c7a0c2
commit 260d5d2d73

View file

@ -10,6 +10,7 @@ import {parse, toSeconds} from 'iso8601-duration';
import {TYPES} from '../types'; import {TYPES} from '../types';
import {inject, injectable} from 'inversify'; import {inject, injectable} from 'inversify';
import {QueuedSong, QueuedPlaylist} from '../services/queue'; import {QueuedSong, QueuedPlaylist} from '../services/queue';
import {STATUS} from '../services/player';
import QueueManager from '../managers/queue'; import QueueManager from '../managers/queue';
import PlayerManager from '../managers/player'; import PlayerManager from '../managers/player';
import {getMostPopularVoiceChannel} from '../utils/channels'; import {getMostPopularVoiceChannel} from '../utils/channels';
@ -214,11 +215,12 @@ export default class implements Command {
// TODO: better response // TODO: better response
await res.stop('song(s) queued'); 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();
}
} }
} }