refactor(configuration): Setup configuration and menu to be reuseable
This commit is contained in:
parent
863ae3fab2
commit
d46bbd84c5
21 changed files with 551 additions and 452 deletions
|
|
@ -7,9 +7,6 @@ import {
|
|||
ChatInputCommandInteraction,
|
||||
time,
|
||||
AttachmentBuilder,
|
||||
ActivityFlagsBitField,
|
||||
Options,
|
||||
User,
|
||||
GuildMember
|
||||
} from "discord.js";
|
||||
import {AutocompleteCommand, ChatInteractionCommand, Command} from "./Command";
|
||||
|
|
@ -21,10 +18,10 @@ import {PlaydateRepository} from "../../Database/Repositories/PlaydateRepository
|
|||
import {GroupModel} from "../../Database/Models/GroupModel";
|
||||
import * as ics from 'ics';
|
||||
import ical from 'node-ical';
|
||||
import {GroupConfigurationHandler} from "../../Configuration/Groups/GroupConfigurationHandler";
|
||||
import {GroupConfigurationRepository} from "../../Database/Repositories/GroupConfigurationRepository";
|
||||
import {privateDecrypt} from "node:crypto";
|
||||
import {GroupRepository} from "../../Database/Repositories/GroupRepository";
|
||||
import {GroupConfigurationProvider} from "../../Configuration/Groups/GroupConfigurationProvider";
|
||||
import { ConfigurationHandler } from "../../Configuration/ConfigurationHandler";
|
||||
|
||||
export class PlaydatesCommand implements Command, AutocompleteCommand, ChatInteractionCommand {
|
||||
definition(): SlashCommandBuilder {
|
||||
|
|
@ -314,10 +311,12 @@ export class PlaydatesCommand implements Command, AutocompleteCommand, ChatInter
|
|||
}
|
||||
|
||||
private async export(interaction: ChatInputCommandInteraction, group: GroupModel): Promise<void> {
|
||||
const groupConfig = new GroupConfigurationHandler(
|
||||
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
|
||||
group
|
||||
).getConfiguration();
|
||||
const groupConfig = new ConfigurationHandler(
|
||||
new GroupConfigurationProvider(
|
||||
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
|
||||
group
|
||||
)
|
||||
).getCompleteConfiguration();
|
||||
|
||||
const playdates = this.getExportTargets(interaction, group);
|
||||
|
||||
|
|
@ -396,10 +395,12 @@ export class PlaydatesCommand implements Command, AutocompleteCommand, ChatInter
|
|||
return false;
|
||||
}
|
||||
|
||||
const config = new GroupConfigurationHandler(
|
||||
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
|
||||
group
|
||||
const config = new ConfigurationHandler(
|
||||
new GroupConfigurationProvider(
|
||||
Container.get<GroupConfigurationRepository>(GroupConfigurationRepository.name),
|
||||
group
|
||||
)
|
||||
);
|
||||
return config.getConfiguration().permissions.allowMemberManagingPlaydates;
|
||||
return config.getConfigurationByPath("permissions.allowMemberManagingPlaydates") === true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue