first attempt at code mostly working

This commit is contained in:
2025-12-12 21:30:26 -08:00
parent 7bc01a3828
commit a840e9385d
32 changed files with 2160 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import express from 'express';
const router = express.Router();
// Get all voice channels
router.get('/', async (req, res) => {
try {
const response = await fetch(`${req.app.locals.botUrl}/channels`);
const result = await response.json();
res.json(result);
} catch (error) {
req.app.locals.logger.error(`Error getting channels: ${error.message}`);
res.status(500).json({ error: 'Failed to get channels' });
}
});
// Join a voice channel
router.post('/join', async (req, res) => {
try {
const { channelId } = req.body;
const response = await fetch(`${req.app.locals.botUrl}/join`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ channelId })
});
const result = await response.json();
if (response.ok) {
req.app.locals.broadcast('channelChange', { channelId, channelName: result.channelName });
}
res.status(response.status).json(result);
} catch (error) {
req.app.locals.logger.error(`Error joining channel: ${error.message}`);
res.status(500).json({ error: 'Failed to join channel' });
}
});
export default router;