con/discon
This commit is contained in:
@@ -503,6 +503,31 @@ app.post('/join', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/disconnect', async (req, res) => {
|
||||
try {
|
||||
if (connection) {
|
||||
connection.destroy();
|
||||
connection = null;
|
||||
|
||||
// Pause playback when disconnecting
|
||||
if (currentState.state === 'playing') {
|
||||
currentState.state = 'paused';
|
||||
if (player) {
|
||||
player.pause();
|
||||
}
|
||||
}
|
||||
|
||||
logger.info('Disconnected from voice channel');
|
||||
res.json({ success: true, message: 'Disconnected from voice channel' });
|
||||
} else {
|
||||
res.json({ success: true, message: 'Already disconnected' });
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(`Failed to disconnect: ${error.message}`);
|
||||
res.status(500).json({ error: 'Failed to disconnect' });
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(INTERNAL_PORT, () => {
|
||||
logger.info(`Internal API listening on port ${INTERNAL_PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user