const botConfig = require('../../../model/botConfig/botConfig.model') const log = require('../../../utils/logger')('internal') // GET /internal/bot-config — called by the bot process on its own boot so a // restart self-reconnects without any admin-panel interaction. Returns the // DECRYPTED token — this route must never be reachable outside the private // compose network (see requireInternalKey + deployment notes). async function getBotConfig(req, res) { try { const config = await botConfig.getWithToken() if (!config) return res.json({ enabled: false, token: null, guildId: null }) return res.json({ enabled: config.enabled, token: config.token, guildId: config.guildId }) } catch (err) { log.error('internal.getBotConfig', err) return res.status(500).json({ message: 'Internal Server Error' }) } } module.exports = { getBotConfig }