Adds Event system and automatic messages

This commit is contained in:
Michel Fedde 2025-05-25 16:07:09 +02:00
parent 0e10ea3cab
commit 2f826fbf36
20 changed files with 428 additions and 18 deletions

View file

@ -34,6 +34,7 @@ import {UserError} from "../Discord/UserError";
import {RuntimeGroupConfiguration} from "./RuntimeGroupConfiguration";
import {ChannelId} from "../types/DiscordTypes";
import {IconCache} from "../Icons/IconCache";
import {ifError} from "node:assert";
type UIElementCollection = Record<string, UIElement>;
type UIElement = {
@ -76,6 +77,19 @@ export class GroupConfigurationRenderer {
key: 'locale',
description: "Provides locale to be used for this group. This mostly sets how the dates are displayed, but this can also be later used for translations.",
isConfiguration: true
},
permissions: {
label: "Permissions",
key: "permissions",
description: "Allows customization, how the members are allowed to interact with the data stored in the group.",
childrenElements: {
allowMemberManagingPlaydates: {
label: "Manage Playdates",
key: "allowMemberManagingPlaydates",
description: "Defines if the members are allowed to manage playdates like adding or deleting them.",
isConfiguration: true
}
}
}
}
@ -220,6 +234,8 @@ export class GroupConfigurationRenderer {
return displaynames.of((<Intl.Locale>value).baseName) ?? "Unknown";
case TransformerType.Channel:
return channelMention(<ChannelId>value);
case TransformerType.PermissionBoolean:
return value ? "Allowed" : "Disallowed"
default:
return "None";
@ -279,6 +295,21 @@ export class GroupConfigurationRenderer {
.setCustomId(GroupConfigurationRenderer.SETVALUE_COMMAND + breadcrumbPath)
.setChannelTypes(ChannelType.GuildText)
.setPlaceholder("New Value");
case TransformerType.PermissionBoolean:
return new StringSelectMenuBuilder()
.setCustomId(GroupConfigurationRenderer.SETVALUE_COMMAND + breadcrumbPath)
.setOptions(
[
{
label: "Allow",
value: "1"
},
{
label: "Disallow",
value: "0"
}
]
)
default:
return new StringSelectMenuBuilder()
@ -309,6 +340,7 @@ export class GroupConfigurationRenderer {
switch (transformerType) {
case TransformerType.Locale:
case TransformerType.Channel:
case TransformerType.PermissionBoolean:
return interaction.values.join('; ');
default:
throw new Error("Unhandled select menu");