ui updates and bot updates. new commands and command handler
This commit is contained in:
25
discord-bot/commands/help.js
Normal file
25
discord-bot/commands/help.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'List available bot commands and what they do.',
|
||||
enabled: true,
|
||||
builder: new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription('List available bot commands and what they do.'),
|
||||
async execute(interaction) {
|
||||
const commands = Array.from(interaction.client.commands.values()).filter(cmd => !!cmd.builder);
|
||||
let text = '**Available Commands:**\n\n';
|
||||
const db = require('../../backend/db').readDb();
|
||||
const guildSettings = db[interaction.guildId] || {};
|
||||
const toggles = guildSettings.commandToggles || {};
|
||||
const protectedCommands = ['manage-commands', 'help'];
|
||||
|
||||
for (const cmd of commands) {
|
||||
const isEnabled = protectedCommands.includes(cmd.name) ? true : (toggles[cmd.name] !== false && cmd.enabled !== false);
|
||||
text += `/${cmd.name} — ${cmd.description || 'No description.'} — ${isEnabled ? 'Enabled' : 'Disabled'}${protectedCommands.includes(cmd.name) ? ' (locked)' : ''}\n`;
|
||||
}
|
||||
|
||||
await interaction.reply({ content: text, flags: 64 });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user