mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-06-07 13:33:13 +02:00
Add auto disconnect
This commit is contained in:
parent
32cb3ca4ae
commit
ac21b5657b
5 changed files with 45 additions and 19 deletions
17
src/events/voice-state-update.ts
Normal file
17
src/events/voice-state-update.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import {VoiceState} from 'discord.js';
|
||||
import container from '../inversify.config';
|
||||
import {TYPES} from '../types';
|
||||
import PlayerManager from '../managers/player';
|
||||
import {getSizeWithoutBots} from '../utils/channels';
|
||||
|
||||
export default (oldState: VoiceState, _: VoiceState): void => {
|
||||
const playerManager = container.get<PlayerManager>(TYPES.Managers.Player);
|
||||
|
||||
const player = playerManager.get(oldState.guild.id);
|
||||
|
||||
if (player.voiceConnection) {
|
||||
if (getSizeWithoutBots(player.voiceConnection.channel) === 0) {
|
||||
player.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue