feat(permissions): Adds server permissions
This commit is contained in:
parent
d46bbd84c5
commit
cf9c88a2d6
24 changed files with 415 additions and 69 deletions
79
source/Discord/Commands/Server.ts
Normal file
79
source/Discord/Commands/Server.ts
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
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<CacheType>): Promise<void> {
|
||||
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>(ServerConfigurationRepository.name),
|
||||
<Snowflake>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: "Group Creation",
|
||||
description: "Defines if all members are allowed to create groups.",
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
),
|
||||
'Server Configuration',
|
||||
"This UI allows you to change settings for your server."
|
||||
)
|
||||
)
|
||||
|
||||
menu.display(interaction);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue