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

@ -9,7 +9,7 @@ import {Nullable} from "../types/Nullable";
import {isPlainObject} from "is-plain-object"; import {isPlainObject} from "is-plain-object";
export class GroupConfigurationHandler { export class GroupConfigurationHandler {
private static DEFAULT_CONFIGURATION: RuntimeGroupConfiguration = { static DEFAULT_CONFIGURATION: RuntimeGroupConfiguration = {
channels: null, channels: null,
locale: new Intl.Locale('en-GB'), locale: new Intl.Locale('en-GB'),
permissions: { permissions: {

View file

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