Adds group configuration

This commit is contained in:
Michel Fedde 2025-04-12 19:41:16 +02:00
parent 0d9cf6a370
commit 154002f6f3
16 changed files with 633 additions and 20 deletions

View file

@ -13,6 +13,10 @@ import {Container} from "../../Container/Container";
import {GroupSelection} from "../CommandPartials/GroupSelection";
import {UserError} from "../UserError";
import {ArrayUtils} from "../../Utilities/ArrayUtils";
import {GroupConfigurationRenderer} from "../../Groups/GroupConfigurationRenderer";
import {GroupConfigurationHandler} from "../../Groups/GroupConfigurationHandler";
import {GroupConfigurationTransformers} from "../../Groups/GroupConfigurationTransformers";
import {GroupConfigurationRepository} from "../../Repositories/GroupConfigurationRepository";
export class GroupCommand implements Command, ChatInteractionCommand, AutocompleteCommand {
private static GOODBYE_MESSAGES: string[] = [
@ -57,7 +61,8 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
.addIntegerOption(GroupSelection.createOptionSetup())
);
}
execute(interaction: ChatInputCommandInteraction): Promise<void> {
async execute(interaction: ChatInputCommandInteraction): Promise<void> {
switch (interaction.options.getSubcommand()) {
case "create":
this.create(interaction);
@ -66,10 +71,11 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
this.list(interaction);
break;
case "remove":
this.remove(interaction);
await this.remove(interaction);
break;
case "config":
this.runConfigurator(interaction);
await this.runConfigurator(interaction);
break;
default:
throw new Error("Unsupported command");
}
@ -159,9 +165,17 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
}
}
private runConfigurator(interaction: ChatInputCommandInteraction) {
private async runConfigurator(interaction: ChatInputCommandInteraction) {
const group = GroupSelection.getGroup(interaction);
const configurationRenderer = new GroupConfigurationRenderer(
new GroupConfigurationHandler(
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
group
),
new GroupConfigurationTransformers(),
)
await configurationRenderer.setup(interaction);
}
}