import {CacheType, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder, Snowflake} from "discord.js"; import {ChatInteractionCommand, Command} from "./Command"; import {GroupSelection} from "../CommandPartials/GroupSelection"; import {MenuHandler} from "../../Configuration/MenuHandler"; import {ConfigurationHandler} from "../../Configuration/ConfigurationHandler"; import {GroupConfigurationProvider} from "../../Configuration/Groups/GroupConfigurationProvider"; import {Container} from "../../Container/Container"; import {GroupConfigurationRepository} from "../../Database/Repositories/GroupConfigurationRepository"; import {MenuRenderer} from "../../Menu/MenuRenderer"; import {MenuTraversal} from "../../Menu/MenuTraversal"; import {MenuItemType} from "../../Menu/MenuRenderer.types"; import {ServerConfigurationProvider} from "../../Configuration/Server/ServerConfigurationProvider"; import {ServerConfigurationRepository} from "../../Database/Repositories/ServerConfigurationRepository"; export class ServerCommand implements Command, ChatInteractionCommand { definition(): SlashCommandBuilder { return new SlashCommandBuilder() .setName("server") .setDescription("Allows server administrators to adjust things about the PnP Scheduler bot.") .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .addSubcommand(command => command .setName("config") .setDescription("Starts the configurator for the server settings") ) } async execute(interaction: ChatInputCommandInteraction): Promise { switch (interaction.options.getSubcommand()) { case "config": await this.startConfiguration(interaction); break } } private async startConfiguration(interaction: ChatInputCommandInteraction) { const menuHandler = new MenuHandler( new ConfigurationHandler( new ServerConfigurationProvider( Container.get(ServerConfigurationRepository.name), interaction.guildId ) ) ) const menu = new MenuRenderer( new MenuTraversal( menuHandler.fillMenuItems( [ { traversalKey: "permissions", label: "Permissions", description: "Allows customization, how the server members are allowed to interact with the PnP Scheduler.", type: MenuItemType.Collection, children: [ { traversalKey: "groupCreation", label: "Group Creation", description: "Sets the permissions, who is allowed to create groups.", type: MenuItemType.Collection, children: [ { traversalKey: "allowEveryone", label: "Allow Anyone", description: "Defines if all members are allowed to create groups.", } ] }, ] }, ] ), 'Server Configuration', "This UI allows you to change settings for your server." ), null, null, "Server" ) menu.display(interaction); } }