Add events module with dashboard UI, scheduling, signups, and settings updates; extend env/readme.
This commit is contained in:
@@ -1,14 +1,43 @@
|
||||
import { REST, Routes, Collection, Client, ChatInputCommandInteraction, GatewayIntentBits } from 'discord.js';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { SlashCommand } from '../utils/types.js';
|
||||
import { env } from '../config/env.js';
|
||||
import { logger } from '../utils/logger.js';
|
||||
import { SlashCommand } from '../utils/types';
|
||||
import { env } from '../config/env';
|
||||
import { logger } from '../utils/logger';
|
||||
import { AdminService } from './adminService';
|
||||
import { StatuspageService } from './statuspageService';
|
||||
import { settingsStore } from '../config/state';
|
||||
import { ModuleKey } from './moduleService';
|
||||
|
||||
export class CommandHandler {
|
||||
private commands = new Collection<string, SlashCommand>();
|
||||
private moduleMap: Record<string, ModuleKey> = {
|
||||
// Tickets
|
||||
ticket: 'ticketsEnabled',
|
||||
ticketpanel: 'ticketsEnabled',
|
||||
transcript: 'ticketsEnabled',
|
||||
close: 'ticketsEnabled',
|
||||
claim: 'ticketsEnabled',
|
||||
// Music
|
||||
play: 'musicEnabled',
|
||||
skip: 'musicEnabled',
|
||||
stop: 'musicEnabled',
|
||||
pause: 'musicEnabled',
|
||||
resume: 'musicEnabled',
|
||||
loop: 'musicEnabled',
|
||||
queue: 'musicEnabled',
|
||||
// Level
|
||||
rank: 'levelingEnabled',
|
||||
// Statuspage
|
||||
status: 'statuspageEnabled',
|
||||
// Birthday
|
||||
birthday: 'birthdayEnabled',
|
||||
// Events
|
||||
event: 'eventsEnabled',
|
||||
events: 'eventsEnabled'
|
||||
};
|
||||
|
||||
constructor(private client: Client) {}
|
||||
constructor(private client: Client, private admin?: AdminService, private statuspage?: StatuspageService) {}
|
||||
|
||||
public async loadCommands() {
|
||||
const commandsPath = path.join(process.cwd(), 'src', 'commands');
|
||||
@@ -80,7 +109,20 @@ export class CommandHandler {
|
||||
await interaction.reply({ content: 'Dieser Befehl funktioniert nur auf Servern.', ephemeral: true });
|
||||
return;
|
||||
}
|
||||
if (interaction.inGuild()) {
|
||||
const moduleKey = this.moduleMap[interaction.commandName];
|
||||
if (moduleKey) {
|
||||
const cfg = settingsStore.get(interaction.guildId!);
|
||||
const enabled = cfg?.[moduleKey];
|
||||
if (enabled === false) {
|
||||
await interaction.reply({ content: 'Dieses Modul ist fuer diese Guild deaktiviert.', ephemeral: true });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.admin?.trackCommand(interaction.guildId);
|
||||
if (interaction.guildId) this.admin?.trackGuildEvent(interaction.guildId, 'commands');
|
||||
await command.execute(interaction, this.client);
|
||||
} catch (err) {
|
||||
logger.error(`Command ${interaction.commandName} failed`, err);
|
||||
|
||||
Reference in New Issue
Block a user