Fixes errors when handling config for new groups

This commit is contained in:
Michel Fedde 2025-05-27 19:28:39 +02:00
parent 8ac59567b9
commit fccc30626a
2 changed files with 12 additions and 5 deletions

View file

@ -8,8 +8,8 @@ import {
ButtonStyle, channelMention,
ChannelSelectMenuBuilder, ChannelSelectMenuInteraction,
ChannelType,
ChatInputCommandInteraction,
EmbedBuilder,
ChatInputCommandInteraction, codeBlock,
EmbedBuilder, inlineCode,
InteractionCallbackResponse,
InteractionEditReplyOptions,
InteractionReplyOptions,
@ -217,7 +217,7 @@ export class GroupConfigurationRenderer {
private getCurrentValueAsUI(): string {
const path = this.breadcrumbs.join(".");
const value = this.configurationHandler.getConfigurationByPath(path);
let value = this.configurationHandler.getConfigurationByPath(path);
if (value === undefined) return italic("None");
@ -229,10 +229,17 @@ export class GroupConfigurationRenderer {
const displaynames = new Intl.DisplayNames(["en"], { type: "language" });
switch (type) {
case TransformerType.Locale:
return displaynames.of((<Intl.Locale>value).baseName) ?? "Unknown";
if (!value) {
return inlineCode("Default");
}
return displaynames.of((<Intl.Locale>value)?.baseName) ?? "Unknown";
case TransformerType.Channel:
if (!value) {
return inlineCode("None");
}
return channelMention(<ChannelId>value);
case TransformerType.PermissionBoolean:
return value ? "Allowed" : "Disallowed"