updated navbar and ui
This commit is contained in:
@@ -73,13 +73,34 @@ app.get('/api/servers/:guildId/settings', (req, res) => {
|
||||
|
||||
app.post('/api/servers/:guildId/settings', (req, res) => {
|
||||
const { guildId } = req.params;
|
||||
const { pingCommand } = req.body;
|
||||
const newSettings = req.body || {};
|
||||
const db = readDb();
|
||||
db[guildId] = { pingCommand };
|
||||
if (!db[guildId]) db[guildId] = {};
|
||||
// Merge incoming settings with existing settings to avoid overwriting unrelated keys
|
||||
db[guildId] = { ...db[guildId], ...newSettings };
|
||||
writeDb(db);
|
||||
res.json({ success: true });
|
||||
});
|
||||
|
||||
// Toggle a single command for a guild (preserves other toggles)
|
||||
app.post('/api/servers/:guildId/commands/:cmdName/toggle', (req, res) => {
|
||||
const { guildId, cmdName } = req.params;
|
||||
const { enabled } = req.body; // boolean
|
||||
const protectedCommands = ['help', 'manage-commands'];
|
||||
if (protectedCommands.includes(cmdName)) {
|
||||
return res.status(403).json({ success: false, message: 'This command is locked and cannot be toggled.' });
|
||||
}
|
||||
const db = readDb();
|
||||
if (!db[guildId]) db[guildId] = {};
|
||||
if (!db[guildId].commandToggles) db[guildId].commandToggles = {};
|
||||
if (typeof enabled === 'boolean') {
|
||||
db[guildId].commandToggles[cmdName] = enabled;
|
||||
writeDb(db);
|
||||
return res.json({ success: true, cmdName, enabled });
|
||||
}
|
||||
return res.status(400).json({ success: false, message: 'Missing or invalid "enabled" boolean in request body' });
|
||||
});
|
||||
|
||||
app.get('/api/servers/:guildId/bot-status', (req, res) => {
|
||||
const { guildId } = req.params;
|
||||
const guild = bot.client.guilds.cache.get(guildId);
|
||||
|
||||
Reference in New Issue
Block a user