Add auto disconnect

This commit is contained in:
Max Isom 2020-03-16 20:14:15 -05:00
parent 32cb3ca4ae
commit ac21b5657b
5 changed files with 45 additions and 19 deletions

View file

@ -36,6 +36,13 @@ export default class implements Command {
}
public async execute(msg: Message, args: string []): Promise<void> {
const [targetVoiceChannel, nInChannel] = getMostPopularVoiceChannel(msg.guild!);
if (nInChannel === 0) {
await msg.channel.send('error: all voice channels are empty');
return;
}
const queue = this.queueManager.get(msg.guild!.id);
if (args.length === 0) {
@ -50,9 +57,7 @@ export default class implements Command {
return;
}
const channel = getMostPopularVoiceChannel(msg.guild!);
await this.playerManager.get(msg.guild!.id).connect(channel);
await this.playerManager.get(msg.guild!.id).connect(targetVoiceChannel);
await this.playerManager.get(msg.guild!.id).play();
await msg.channel.send('play resuming');
@ -252,9 +257,7 @@ export default class implements Command {
await res.stop('song(s) queued');
if (this.playerManager.get(msg.guild!.id).status === STATUS.DISCONNECTED) {
const channel = getMostPopularVoiceChannel(msg.guild!);
await this.playerManager.get(msg.guild!.id).connect(channel);
await this.playerManager.get(msg.guild!.id).connect(targetVoiceChannel);
await this.playerManager.get(msg.guild!.id).play();
}