feat(configuration): Adds missing implermentations
This commit is contained in:
parent
b82ab7dbc4
commit
ec0aa5654c
7 changed files with 150 additions and 32 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
AnyMenuItem, FieldMenuItem,
|
||||
FieldMenuItemContext, FieldMenuItemSaveValue,
|
||||
MenuItemType,
|
||||
FieldMenuItemContext, FieldMenuItemSaveValue, MenuItem,
|
||||
MenuItemType, PromptMenuItem,
|
||||
RowBuilderFieldMenuItemContext
|
||||
} from "../Menu/MenuRenderer.types";
|
||||
import {GroupConfigurationTransformers} from "./GroupConfigurationTransformers";
|
||||
|
|
@ -18,6 +18,7 @@ import {
|
|||
} from "discord.js";
|
||||
import {ChannelId} from "../types/DiscordTypes";
|
||||
import {MessageActionRowComponentBuilder} from "@discordjs/builders";
|
||||
import {Prompt} from "../Menu/Modals/Prompt";
|
||||
|
||||
export class ConfigurationMenuHandler {
|
||||
|
||||
|
|
@ -56,15 +57,6 @@ export class ConfigurationMenuHandler {
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
traversalKey: "locale",
|
||||
label: "Locale",
|
||||
description: "Provides locale to be used for this group.",
|
||||
type: MenuItemType.Field,
|
||||
getCurrentValue: this.getLocaleValue.bind(this),
|
||||
getActionRowBuilder: this.getLocaleMenuBuilder.bind(this),
|
||||
setValue: this.setValue.bind(this)
|
||||
},
|
||||
{
|
||||
traversalKey: "permissions",
|
||||
label: "Permissions",
|
||||
|
|
@ -88,20 +80,45 @@ export class ConfigurationMenuHandler {
|
|||
description: "Provides settings for the metadata contained in the playdate exports.",
|
||||
type: MenuItemType.Collection,
|
||||
children: [
|
||||
{
|
||||
this.createStringMenuItem({
|
||||
traversalKey: "title",
|
||||
label: "Title",
|
||||
description: "Defines how the calendar entry should be called.",
|
||||
type: MenuItemType.Prompt,
|
||||
getCurrentValue: this.getStringValue.bind(this),
|
||||
getActionRowBuilder: this.getStringBuilder.bind(this),
|
||||
setValue: this.setValue.bind(this)
|
||||
}
|
||||
}),
|
||||
this.createTextareaMenuItem({
|
||||
traversalKey: "description",
|
||||
label: "Description",
|
||||
description: "Sets the description for the calendar entry.",
|
||||
}),
|
||||
this.createStringMenuItem({
|
||||
traversalKey: "location",
|
||||
label: "Location",
|
||||
description: "Sets the location where the calendar should point to."
|
||||
}),
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
private createStringMenuItem(metadata: MenuItem): PromptMenuItem {
|
||||
return {
|
||||
...metadata,
|
||||
type: MenuItemType.Prompt,
|
||||
getCurrentValue: this.getStringValue.bind(this),
|
||||
getActionRowBuilder: this.getStringBuilder.bind(this),
|
||||
setValue: this.setValue.bind(this)
|
||||
};
|
||||
}
|
||||
private createTextareaMenuItem(metadata: MenuItem): PromptMenuItem {
|
||||
return {
|
||||
...metadata,
|
||||
type: MenuItemType.Prompt,
|
||||
getCurrentValue: this.getStringValue.bind(this),
|
||||
getActionRowBuilder: this.getTextareaBuilder.bind(this),
|
||||
setValue: this.setValue.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
private getChannelValue(context: FieldMenuItemContext): string {
|
||||
const value = this.configuration.getConfigurationByPath(context.path.join('.'));
|
||||
if (value === undefined) {
|
||||
|
|
@ -193,6 +210,11 @@ export class ConfigurationMenuHandler {
|
|||
return new TextInputBuilder()
|
||||
.setStyle(TextInputStyle.Short)
|
||||
}
|
||||
private getTextareaBuilder(context: FieldMenuItemContext): TextInputBuilder {
|
||||
return new TextInputBuilder()
|
||||
.setStyle(TextInputStyle.Paragraph)
|
||||
}
|
||||
|
||||
|
||||
private setValue(value: FieldMenuItemSaveValue[]|string, context: FieldMenuItemContext): void {
|
||||
const savedValue = typeof value !== 'string' ?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue