import { ContainerBuilder, type RGBTuple } from '@discordjs/builders'; import { ComponentType } from 'discord.js'; export namespace Container { export type ContainerOptions = { components: any[]; accentColor?: RGBTuple | number; spoiler?: boolean; }; export function Create(options: ContainerOptions) { console.log('Creating container with options:', options); const container = new ContainerBuilder({ components: options.components.map((component) => { console.log('Processing component:', component); switch (component.type) { case ComponentType.TextDisplay: return { type: ComponentType.TextDisplay, content: component.content ?? '', }; case ComponentType.MediaGallery: return { type: ComponentType.MediaGallery, items: component.items ?? [], }; case ComponentType.ActionRow: return { type: ComponentType.ActionRow, components: component.components ?? [], }; case ComponentType.File: return { type: ComponentType.File, file: component.file, }; case ComponentType.Separator: return { type: ComponentType.Separator, }; case ComponentType.Section: return { type: ComponentType.Section, components: component.components ?? [], accessory: component.accessory ?? [], }; default: console.error('Unsupported component type:', component.type); throw new Error(`Unsupported component type: ${component.type}`); } }) ?? [], }); if (options.accentColor !== undefined) { console.log('Setting accent color:', options.accentColor); container.setAccentColor(options.accentColor); } if (options.spoiler !== undefined) { console.log('Setting spoiler:', options.spoiler); container.setSpoiler(options.spoiler); } console.log('Container created successfully:', container); return container; } }