Adds group configuration
This commit is contained in:
parent
0d9cf6a370
commit
154002f6f3
16 changed files with 633 additions and 20 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -38,13 +38,6 @@ export class DiscordClient {
|
|||
})
|
||||
|
||||
this.client.on(Events.InteractionCreate, async (interaction: Interaction) => {
|
||||
const command = this.commands.getCommand(interaction.commandName);
|
||||
|
||||
if (command === null) {
|
||||
Container.get<Logger>("logger").error(`Could not find command for '${interaction.commandName}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
const method = this.findCommandMethod(interaction);
|
||||
if (!method) {
|
||||
Container.get<Logger>("logger").error(`Could not find method for '${interaction.commandName}'`);
|
||||
|
|
@ -77,7 +70,7 @@ export class DiscordClient {
|
|||
try {
|
||||
await command.execute(interaction)
|
||||
}
|
||||
catch (e: Error) {
|
||||
catch (e: any) {
|
||||
Container.get<Logger>("logger").error(e)
|
||||
|
||||
let userMessage = ":x: There was an error while executing this command!";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue