ui updates and bot updates. new commands and command handler

This commit is contained in:
2025-10-03 19:53:23 -04:00
parent 524a6cc633
commit f63fca3f1b
20 changed files with 831 additions and 125 deletions

View File

@@ -2,6 +2,7 @@ const { Client, GatewayIntentBits, Collection } = require('discord.js');
const fs = require('fs');
const path = require('path');
const deployCommands = require('./deploy-commands');
const { readDb } = require('../backend/db');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] });
@@ -20,11 +21,35 @@ client.on('interactionCreate', async interaction => {
if (!command) return;
// Check per-guild toggles
try {
await command.execute(interaction);
const db = readDb();
const guildSettings = db[interaction.guildId] || {};
const toggles = guildSettings.commandToggles || {};
const protectedCommands = ['manage-commands', 'help'];
// If command is protected, always allow
if (!protectedCommands.includes(command.name)) {
if (toggles[command.name] === false) {
await interaction.reply({ content: 'This command has been disabled on this server.', flags: 64 });
return;
}
// If the module-level enabled flag is false, treat as disabled too
if (command.enabled === false) {
await interaction.reply({ content: 'This command is currently disabled globally.', flags: 64 });
return;
}
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', flags: 64 });
}
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
console.error('Error checking command toggles:', error);
await interaction.reply({ content: 'Internal error occurred.', flags: 64 });
}
});