import type { APISeparatorComponent } from "discord.js"; import { SeparatorSpacingSize, ComponentType } from "discord.js"; /** * A class for creating a separator component */ export class V2Separator { private id?: number; private divider = true; private spacing: SeparatorSpacingSize = SeparatorSpacingSize.Small; private readonly type = ComponentType.Separator; /** * Set the id of the separator * @param id - The id of the separator * @returns The separator instance */ setId(id: number) { this.id = id; return this; } /** * Set the spacing of the separator * @param spacing - The spacing size (1 = small or 2 = large) * @returns The separator instance */ setSpacing(spacing: SeparatorSpacingSize) { this.spacing = spacing; return this; } /** * Set whether to show the divider line * @param show - Whether to show the divider line * @returns The separator instance */ setDivider(show: boolean) { this.divider = show; return this; } /** * Convert the separator to a JSON object * @returns The JSON representation of the separator */ toJSON(): APISeparatorComponent { return { type: this.type, spacing: this.spacing, divider: this.divider, ...(this.id !== undefined && { id: this.id }), }; } } /** * Helper function to create a separator component * @param options - Optional configuration for the separator * @returns A separator component ready to use in Discord messages */ export function makeSeparator(options?: { spacing?: SeparatorSpacingSize; divider?: boolean; id?: number; }): APISeparatorComponent { const separator = new V2Separator(); if (options?.spacing !== undefined) separator.setSpacing(options.spacing); if (options?.divider !== undefined) separator.setDivider(options.divider); if (options?.id !== undefined) separator.setId(options.id); return separator.toJSON(); }