seedcord 0.12.0-next.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,85 +1,5 @@
1
1
  import { ActionRowBuilder, ButtonBuilder, ChannelSelectMenuBuilder, CheckboxBuilder, CheckboxGroupBuilder, CheckboxGroupOptionBuilder, ContainerBuilder, ContextMenuCommandBuilder, EmbedBuilder, FileBuilder, FileUploadBuilder, LabelBuilder, MediaGalleryBuilder, MentionableSelectMenuBuilder, ModalBuilder, RadioGroupBuilder, RadioGroupOptionBuilder, RoleSelectMenuBuilder, SectionBuilder, SeparatorBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextDisplayBuilder, TextInputBuilder, UserSelectMenuBuilder } from "discord.js";
2
2
 
3
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/non-empty-tuple.d.ts
4
- /**
5
- Matches any non-empty tuple.
6
-
7
- @example
8
- ```
9
- import type {NonEmptyTuple} from 'type-fest';
10
-
11
- const sum = (...numbers: NonEmptyTuple<number>) => numbers.reduce((total, value) => total + value, 0);
12
-
13
- sum(1, 2, 3);
14
- // Ok
15
-
16
- // @ts-expect-error
17
- sum();
18
- // Error: Expected at least 1 arguments, but got 0.
19
- ```
20
-
21
- @see {@link RequireAtLeastOne} for objects
22
-
23
- @category Array
24
- */
25
- type NonEmptyTuple<T = unknown> = readonly [T, ...T[]];
26
- //#endregion
27
- //#region ../../node_modules/.pnpm/type-fest@5.6.0/node_modules/type-fest/source/join.d.ts
28
- // The builtin `join` method supports all these natively in the same way that typescript handles them so we can safely accept all of them.
29
- type JoinableItem = string | number | bigint | boolean | undefined | null; // `null` and `undefined` are treated uniquely in the built-in join method, in a way that differs from the default `toString` that would result in the type `${undefined}`. That's why we need to handle it specifically with this helper.
30
- // @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join#description
31
- type NullishCoalesce<Value extends JoinableItem, Fallback extends string> = Value extends undefined | null ? NonNullable<Value> | Fallback : Value;
32
- /**
33
- Join an array of strings and/or numbers using the given string as a delimiter.
34
-
35
- Use-case: Defining key paths in a nested object. For example, for dot-notation fields in MongoDB queries.
36
-
37
- @example
38
- ```
39
- import type {Join} from 'type-fest';
40
-
41
- // Mixed (strings & numbers) items
42
- const path1 = ['foo', 0, 'baz'].join('.') as Join<['foo', 0, 'baz'], '.'>;
43
- //=> 'foo.0.baz'
44
-
45
- // Only string items
46
- const path2 = ['foo', 'bar', 'baz'].join('.') as Join<['foo', 'bar', 'baz'], '.'>;
47
- //=> 'foo.bar.baz'
48
-
49
- // Only number items
50
- const path3 = [1, 2, 3].join('.') as Join<[1, 2, 3], '.'>;
51
- //=> '1.2.3'
52
-
53
- // Only bigint items
54
- const path4 = [1n, 2n, 3n].join('.') as Join<[1n, 2n, 3n], '.'>;
55
- //=> '1.2.3'
56
-
57
- // Only boolean items
58
- const path5 = [true, false, true].join('.') as Join<[true, false, true], '.'>;
59
- //=> 'true.false.true'
60
-
61
- // Contains nullish items
62
- const path6 = ['foo', undefined, 'baz', null, 'xyz'].join('.') as Join<['foo', undefined, 'baz', null, 'xyz'], '.'>;
63
- //=> 'foo..baz..xyz'
64
-
65
- // Partial tuple shapes (rest param last)
66
- const path7 = ['prefix'].join('.') as Join<['prefix', ...string[]], '.'>;
67
- //=> `prefix.${string}`
68
-
69
- // Partial tuple shapes (rest param first)
70
- const path8 = ['suffix'].join('.') as Join<[...string[], 'suffix'], '.'>;
71
- //=> `${string}.suffix`
72
-
73
- // Tuples items with nullish unions
74
- const path9 = ['hello', 'world'].join('.') as Join<['hello' | undefined, 'world' | null], '.'>;
75
- //=> '.' | '.world' | 'hello.' | 'hello.world'
76
- ```
77
-
78
- @category Array
79
- @category Template literal
80
- */
81
- type Join<Items extends readonly JoinableItem[], Delimiter extends string> = Items extends readonly [] ? '' : Items extends readonly [JoinableItem?] ? `${NullishCoalesce<Items[0], ''>}` : Items extends readonly [infer First extends JoinableItem, ...infer Tail extends readonly JoinableItem[]] ? `${NullishCoalesce<First, ''>}${Delimiter}${Join<Tail, Delimiter>}` : Items extends readonly [...infer Head extends readonly JoinableItem[], infer Last extends JoinableItem] ? `${Join<Head, Delimiter>}${Delimiter}${NullishCoalesce<Last, ''>}` : string;
82
- //#endregion
83
3
  //#region src/interfaces/Components.d.ts
84
4
  /**
85
5
  * Available Discord.js builder classes for use with BuilderComponent for commands, embeds, modals, etc.
@@ -174,24 +94,6 @@ declare abstract class BaseComponent<TComponent> {
174
94
  * @example this.instance.setTitle('My Modal')
175
95
  */
176
96
  protected get instance(): TComponent;
177
- /**
178
- * Builds a customId string for interactive components with no arguments
179
- *
180
- * @param prefix - The route prefix that handlers will match against
181
- * @returns The prefix as the customId
182
- */
183
- buildCustomId<Prefix extends string>(prefix: Prefix): Prefix;
184
- /**
185
- * Builds a customId string for interactive components
186
- *
187
- * Creates customIds in the format `prefix:arg1-arg2-arg3` for buttons, modals, etc.
188
- * Arguments are joined with hyphens and separated from prefix with a colon.
189
- *
190
- * @param prefix - The route prefix that handlers will match against
191
- * @param args - Additional arguments to encode in the customId
192
- * @returns Formatted customId string
193
- */
194
- buildCustomId<Prefix extends string, Args extends NonEmptyTuple<string>>(prefix: Prefix, ...args: Args): `${Prefix}:${Join<Args, '-'>}`;
195
97
  }
196
98
  /**
197
99
  * Base class for Discord.js builder components
@@ -245,5 +147,5 @@ declare abstract class CustomError extends Error {
245
147
  set emit(value: boolean);
246
148
  }
247
149
  //#endregion
248
- export { RowType as a, RowComponent as i, BuilderType as n, NonEmptyTuple as o, CustomError as r, BuilderComponent as t };
249
- //# sourceMappingURL=Components-BS8zPPq7.d.mts.map
150
+ export { RowType as a, RowComponent as i, BuilderType as n, CustomError as r, BuilderComponent as t };
151
+ //# sourceMappingURL=Components-Drs0KoOi.d.mts.map
@@ -86,9 +86,6 @@ var BaseComponent = class {
86
86
  get instance() {
87
87
  return this._component;
88
88
  }
89
- buildCustomId(prefix, ...args) {
90
- return args.length === 0 ? prefix : `${prefix}:${args.join("-")}`;
91
- }
92
89
  };
93
90
  /**
94
91
  * Base class for Discord.js builder components
@@ -219,4 +216,4 @@ var DatabaseError = class extends CustomError {
219
216
 
220
217
  //#endregion
221
218
  export { setBotColor as a, RowComponent as i, BuilderComponent as n, CustomError as r, DatabaseError as t };
222
- //# sourceMappingURL=Database-D-mgXwZ_.mjs.map
219
+ //# sourceMappingURL=Database-DAWd3hyw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Database-DAWd3hyw.mjs","names":[],"sources":["../src/miscellaneous/botColorHolder.ts","../src/interfaces/Components.ts","../src/bot/defaults/errors/Database.ts"],"sourcesContent":["import type { ColorResolvable } from 'discord.js';\n\n// 'Default' is Discord.js's own sentinel for \"no explicit color\".\nconst DEFAULT_COLOR: ColorResolvable = 'Default';\n\nlet current: ColorResolvable = DEFAULT_COLOR;\n\n/** @internal */\nexport function setBotColor(color: ColorResolvable | undefined): void {\n current = color ?? DEFAULT_COLOR;\n}\n\n/** @internal */\nexport function getBotColor(): ColorResolvable {\n return current;\n}\n","import {\n ActionRowBuilder,\n ButtonBuilder,\n ChannelSelectMenuBuilder,\n CheckboxBuilder,\n CheckboxGroupBuilder,\n CheckboxGroupOptionBuilder,\n ContainerBuilder,\n ContextMenuCommandBuilder,\n EmbedBuilder,\n FileBuilder,\n FileUploadBuilder,\n InteractionContextType,\n LabelBuilder,\n MediaGalleryBuilder,\n MentionableSelectMenuBuilder,\n ModalBuilder,\n RadioGroupBuilder,\n RadioGroupOptionBuilder,\n RoleSelectMenuBuilder,\n SectionBuilder,\n SeparatorBuilder,\n SlashCommandBuilder,\n SlashCommandSubcommandBuilder,\n SlashCommandSubcommandGroupBuilder,\n StringSelectMenuBuilder,\n StringSelectMenuOptionBuilder,\n TextDisplayBuilder,\n TextInputBuilder,\n UserSelectMenuBuilder,\n resolveColor\n} from 'discord.js';\n\nimport { getBotColor } from '@miscellaneous/botColorHolder';\n\n/**\n * Available Discord.js builder classes for use with BuilderComponent for commands, embeds, modals, etc.\n *\n * @internal\n */\nexport const BuilderTypes = {\n // Command Components\n command: SlashCommandBuilder,\n context_menu: ContextMenuCommandBuilder,\n subcommand: SlashCommandSubcommandBuilder,\n group: SlashCommandSubcommandGroupBuilder,\n\n // Embed Components\n embed: EmbedBuilder,\n\n // Modal Components\n modal: ModalBuilder,\n label: LabelBuilder,\n text_input: TextInputBuilder,\n file_upload: FileUploadBuilder,\n checkbox: CheckboxBuilder,\n checkbox_group: CheckboxGroupBuilder,\n checkbox_group_option: CheckboxGroupOptionBuilder,\n radio_group: RadioGroupBuilder,\n radio_group_option: RadioGroupOptionBuilder,\n\n // Action Row Components\n button: ButtonBuilder,\n menu_string: StringSelectMenuBuilder,\n menu_option_string: StringSelectMenuOptionBuilder,\n menu_user: UserSelectMenuBuilder,\n menu_channel: ChannelSelectMenuBuilder,\n menu_mentionable: MentionableSelectMenuBuilder,\n menu_role: RoleSelectMenuBuilder,\n\n // ComponentsV2\n container: ContainerBuilder,\n text_display: TextDisplayBuilder,\n file: FileBuilder,\n media: MediaGalleryBuilder,\n section: SectionBuilder,\n separator: SeparatorBuilder\n};\n\n/**\n * Available Discord.js action row classes for use with RowComponent for Select Menus and Buttons\n *\n * @internal\n */\nexport const RowTypes: {\n button: typeof ActionRowBuilder<ButtonBuilder>;\n menu_string: typeof ActionRowBuilder<StringSelectMenuBuilder>;\n menu_user: typeof ActionRowBuilder<UserSelectMenuBuilder>;\n menu_channel: typeof ActionRowBuilder<ChannelSelectMenuBuilder>;\n menu_mentionable: typeof ActionRowBuilder<MentionableSelectMenuBuilder>;\n menu_role: typeof ActionRowBuilder<RoleSelectMenuBuilder>;\n} = {\n button: ActionRowBuilder<ButtonBuilder>,\n menu_string: ActionRowBuilder<StringSelectMenuBuilder>,\n menu_user: ActionRowBuilder<UserSelectMenuBuilder>,\n menu_channel: ActionRowBuilder<ChannelSelectMenuBuilder>,\n menu_mentionable: ActionRowBuilder<MentionableSelectMenuBuilder>,\n menu_role: ActionRowBuilder<RoleSelectMenuBuilder>\n};\n\n/**\n * Available Discord.js builder types for use with BuilderComponent\n */\nexport type BuilderType = keyof typeof BuilderTypes;\n\n/**\n * @internal\n */\nexport type InstantiatedBuilder<BuilderKey extends BuilderType> = InstanceType<(typeof BuilderTypes)[BuilderKey]>;\n\n/**\n * Available Discord.js action row types for use with RowComponent\n */\nexport type RowType = keyof typeof RowTypes;\n\n/**\n * @internal\n */\nexport type InstantiatedActionRow<RowKey extends RowType> = InstanceType<(typeof RowTypes)[RowKey]>;\n\n/**\n * Base class for Discord component wrappers\n *\n * Provides common functionality for building Discord components with proper typing.\n *\n * @typeParam TComponent - The Discord.js component type being wrapped\n *\n * @internal\n */\nexport abstract class BaseComponent<TComponent> {\n private readonly _component: TComponent;\n\n protected constructor(ComponentClass: new () => TComponent) {\n this._component = new ComponentClass();\n }\n\n /**\n * Gets the built component (should be considered read-only)\n *\n * Returns the finalized component ready for use in Discord messages.\n *\n * Please do not use for further configuration, use `this.instance` for that.\n * @example new SomeComponent().component\n */\n public abstract get component(): InstantiatedBuilder<BuilderType> | InstantiatedActionRow<RowType>;\n\n /**\n * Gets the component instance for configuration\n *\n * Use this to access Discord.js builder methods like setTitle(), setDescription(), etc.\n *\n * Use this in your component classes to configure the builder\n * @example this.instance.setTitle('My Modal')\n */\n protected get instance(): TComponent {\n return this._component;\n }\n}\n\n/**\n * Base class for Discord.js builder components\n *\n * Wraps Discord.js builders (SlashCommandBuilder, EmbedBuilder, etc.) with\n * Seedcord-specific defaults and helper methods.\n *\n * @typeParam BuilderKey - The type of Discord.js builder being wrapped\n */\nexport abstract class BuilderComponent<BuilderKey extends BuilderType> extends BaseComponent<\n InstantiatedBuilder<BuilderKey>\n> {\n private colorApplied = false;\n\n protected constructor(public readonly type: BuilderKey) {\n const ComponentClass = BuilderTypes[type] as unknown;\n super(ComponentClass as new () => InstantiatedBuilder<BuilderKey>);\n\n if (this.instance instanceof SlashCommandBuilder || this.instance instanceof ContextMenuCommandBuilder) {\n this.instance.setContexts(InteractionContextType.Guild);\n }\n }\n\n get component(): InstantiatedBuilder<BuilderKey> {\n this.applyBotColor();\n return this.instance;\n }\n\n // Resolving in the constructor would capture the default for a component built before setBotColor()\n // ran. The unset check keeps a color the subclass set for itself.\n private applyBotColor(): void {\n if (this.colorApplied) return;\n this.colorApplied = true;\n\n const color = getBotColor();\n if (this.instance instanceof EmbedBuilder) {\n if (this.instance.data.color === undefined) this.instance.setColor(color);\n } else if (this.instance instanceof ContainerBuilder) {\n const accent = this.instance.data.accent_color;\n if (accent === null || accent === undefined) {\n this.instance.setAccentColor(color === 'Default' ? undefined : resolveColor(color));\n }\n }\n }\n}\n\n/**\n * Base class for Discord action row components\n *\n * Wraps Discord.js action row builder with Seedcord-specific defaults and helper methods.\n *\n * @typeParam RowKey - The Discord.js action row type being wrapped\n */\nexport abstract class RowComponent<RowKey extends RowType> extends BaseComponent<InstantiatedActionRow<RowKey>> {\n protected constructor(public readonly type: RowKey) {\n const ComponentClass = RowTypes[type] as unknown;\n super(ComponentClass as new () => InstantiatedActionRow<RowKey>);\n }\n\n get component(): InstantiatedActionRow<RowKey> {\n return this.instance;\n }\n}\n\n/**\n * Pre-configured error embed with default styling\n *\n * This is bundled in {@link CustomError}s as the response.\n *\n * @internal\n */\nexport class BaseErrorEmbed extends BuilderComponent<'embed'> {\n /**\n * Creates a new error embed with default configuration.\n */\n public constructor() {\n super('embed');\n this.instance.setTitle('Cannot Proceed');\n }\n}\n\n/**\n * Base class for custom error types with Discord embed responses\n *\n * Errors extending CustomError should be used with the `Catchable` decorators to implement a control flow. These errors will be caught and handled by the framework to show the user the configured response.\n */\nexport abstract class CustomError extends Error {\n private _emit = false;\n public readonly response = new BaseErrorEmbed().component;\n\n protected constructor(public override message: string) {\n super(message);\n\n Error.captureStackTrace(this, this.constructor);\n }\n\n /**\n * Whether this error should be emitted to logs\n *\n * Controls logging behavior. Errors with emit=true will always be logged,\n * while emit=false errors may be suppressed in production.\n *\n * @returns True if the error should be logged\n */\n public get emit(): boolean {\n return this._emit;\n }\n\n /**\n * Sets whether this error should be emitted to logs\n */\n public set emit(value: boolean) {\n this._emit = value;\n }\n}\n","import { CustomError } from '@interfaces/Components';\n\nimport type { UUID } from 'crypto';\n\n/**\n * Generic database operation error with UUID tracking.\n *\n * Thrown for various database operation failures and includes\n * a UUID for error tracking and debugging purposes.\n *\n * @internal\n */\nexport class DatabaseError extends CustomError {\n /**\n * Creates a new DatabaseError.\n *\n * @param message - The error message describing what went wrong\n * @param uuid - A unique identifier for this specific error instance\n */\n constructor(\n message: string,\n public uuid: UUID\n ) {\n super(message);\n this.emit = true; // Emit in logs regardless of environment\n this.name = 'DatabaseError';\n\n this.response\n .setTitle('Database Error')\n .setDescription(`An error occurred while interacting with the database.\\n### UUID: \\`${this.uuid}\\``);\n }\n}\n"],"mappings":";;;AAGA,MAAM,gBAAiC;AAEvC,IAAI,UAA2B;;AAG/B,SAAgB,YAAY,OAA0C;CAClE,UAAU,SAAS;AACvB;;AAGA,SAAgB,cAA+B;CAC3C,OAAO;AACX;;;;;;;;;ACyBA,MAAa,eAAe;CAExB,SAAS;CACT,cAAc;CACd,YAAY;CACZ,OAAO;CAGP,OAAO;CAGP,OAAO;CACP,OAAO;CACP,YAAY;CACZ,aAAa;CACb,UAAU;CACV,gBAAgB;CAChB,uBAAuB;CACvB,aAAa;CACb,oBAAoB;CAGpB,QAAQ;CACR,aAAa;CACb,oBAAoB;CACpB,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,WAAW;CAGX,WAAW;CACX,cAAc;CACd,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW;AACf;;;;;;AAOA,MAAa,WAOT;CACA,QAAQ;CACR,aAAa;CACb,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,WAAW;AACf;;;;;;;;;;AA+BA,IAAsB,gBAAtB,MAAgD;CAC5C,AAAiB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AAe,EAAE;CAEhD,AAAU,YAAY,AAAgB,SAAiB;EACnD,MAAM,OAAO;EADqB;EAGlC,MAAM,kBAAkB,MAAM,KAAK,WAAW;CAClD;;;;;;;;;CAUA,IAAW,OAAgB;EACvB,OAAO,KAAK;CAChB;;;;CAKA,IAAW,KAAK,OAAgB;EAC5B,KAAK,QAAQ;CACjB;AACJ;;;;;;;;;;;;ACpQA,IAAa,gBAAb,cAAmC,YAAY;CAShC;;;;;;;CAFX,YACI,SACA,AAAO,MACT;EACE,MAAM,OAAO;EAFN;EAGP,KAAK,OAAO;EACZ,KAAK,OAAO;EAEZ,KAAK,SACA,SAAS,gBAAgB,EACzB,eAAe,uEAAuE,KAAK,KAAK,GAAG;CAC5G;AACJ"}
@@ -86,9 +86,6 @@ var BaseComponent = class {
86
86
  get instance() {
87
87
  return this._component;
88
88
  }
89
- buildCustomId(prefix, ...args) {
90
- return args.length === 0 ? prefix : `${prefix}:${args.join("-")}`;
91
- }
92
89
  };
93
90
  /**
94
91
  * Base class for Discord.js builder components
@@ -248,4 +245,4 @@ Object.defineProperty(exports, 'setBotColor', {
248
245
  return setBotColor;
249
246
  }
250
247
  });
251
- //# sourceMappingURL=Database-Dx7bRFrY.cjs.map
248
+ //# sourceMappingURL=Database-DTVbdvLZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Database-DTVbdvLZ.cjs","names":["SlashCommandBuilder","ContextMenuCommandBuilder","SlashCommandSubcommandBuilder","SlashCommandSubcommandGroupBuilder","EmbedBuilder","ModalBuilder","LabelBuilder","TextInputBuilder","FileUploadBuilder","CheckboxBuilder","CheckboxGroupBuilder","CheckboxGroupOptionBuilder","RadioGroupBuilder","RadioGroupOptionBuilder","ButtonBuilder","StringSelectMenuBuilder","StringSelectMenuOptionBuilder","UserSelectMenuBuilder","ChannelSelectMenuBuilder","MentionableSelectMenuBuilder","RoleSelectMenuBuilder","ContainerBuilder","TextDisplayBuilder","FileBuilder","MediaGalleryBuilder","SectionBuilder","SeparatorBuilder","ActionRowBuilder","InteractionContextType"],"sources":["../src/miscellaneous/botColorHolder.ts","../src/interfaces/Components.ts","../src/bot/defaults/errors/Database.ts"],"sourcesContent":["import type { ColorResolvable } from 'discord.js';\n\n// 'Default' is Discord.js's own sentinel for \"no explicit color\".\nconst DEFAULT_COLOR: ColorResolvable = 'Default';\n\nlet current: ColorResolvable = DEFAULT_COLOR;\n\n/** @internal */\nexport function setBotColor(color: ColorResolvable | undefined): void {\n current = color ?? DEFAULT_COLOR;\n}\n\n/** @internal */\nexport function getBotColor(): ColorResolvable {\n return current;\n}\n","import {\n ActionRowBuilder,\n ButtonBuilder,\n ChannelSelectMenuBuilder,\n CheckboxBuilder,\n CheckboxGroupBuilder,\n CheckboxGroupOptionBuilder,\n ContainerBuilder,\n ContextMenuCommandBuilder,\n EmbedBuilder,\n FileBuilder,\n FileUploadBuilder,\n InteractionContextType,\n LabelBuilder,\n MediaGalleryBuilder,\n MentionableSelectMenuBuilder,\n ModalBuilder,\n RadioGroupBuilder,\n RadioGroupOptionBuilder,\n RoleSelectMenuBuilder,\n SectionBuilder,\n SeparatorBuilder,\n SlashCommandBuilder,\n SlashCommandSubcommandBuilder,\n SlashCommandSubcommandGroupBuilder,\n StringSelectMenuBuilder,\n StringSelectMenuOptionBuilder,\n TextDisplayBuilder,\n TextInputBuilder,\n UserSelectMenuBuilder,\n resolveColor\n} from 'discord.js';\n\nimport { getBotColor } from '@miscellaneous/botColorHolder';\n\n/**\n * Available Discord.js builder classes for use with BuilderComponent for commands, embeds, modals, etc.\n *\n * @internal\n */\nexport const BuilderTypes = {\n // Command Components\n command: SlashCommandBuilder,\n context_menu: ContextMenuCommandBuilder,\n subcommand: SlashCommandSubcommandBuilder,\n group: SlashCommandSubcommandGroupBuilder,\n\n // Embed Components\n embed: EmbedBuilder,\n\n // Modal Components\n modal: ModalBuilder,\n label: LabelBuilder,\n text_input: TextInputBuilder,\n file_upload: FileUploadBuilder,\n checkbox: CheckboxBuilder,\n checkbox_group: CheckboxGroupBuilder,\n checkbox_group_option: CheckboxGroupOptionBuilder,\n radio_group: RadioGroupBuilder,\n radio_group_option: RadioGroupOptionBuilder,\n\n // Action Row Components\n button: ButtonBuilder,\n menu_string: StringSelectMenuBuilder,\n menu_option_string: StringSelectMenuOptionBuilder,\n menu_user: UserSelectMenuBuilder,\n menu_channel: ChannelSelectMenuBuilder,\n menu_mentionable: MentionableSelectMenuBuilder,\n menu_role: RoleSelectMenuBuilder,\n\n // ComponentsV2\n container: ContainerBuilder,\n text_display: TextDisplayBuilder,\n file: FileBuilder,\n media: MediaGalleryBuilder,\n section: SectionBuilder,\n separator: SeparatorBuilder\n};\n\n/**\n * Available Discord.js action row classes for use with RowComponent for Select Menus and Buttons\n *\n * @internal\n */\nexport const RowTypes: {\n button: typeof ActionRowBuilder<ButtonBuilder>;\n menu_string: typeof ActionRowBuilder<StringSelectMenuBuilder>;\n menu_user: typeof ActionRowBuilder<UserSelectMenuBuilder>;\n menu_channel: typeof ActionRowBuilder<ChannelSelectMenuBuilder>;\n menu_mentionable: typeof ActionRowBuilder<MentionableSelectMenuBuilder>;\n menu_role: typeof ActionRowBuilder<RoleSelectMenuBuilder>;\n} = {\n button: ActionRowBuilder<ButtonBuilder>,\n menu_string: ActionRowBuilder<StringSelectMenuBuilder>,\n menu_user: ActionRowBuilder<UserSelectMenuBuilder>,\n menu_channel: ActionRowBuilder<ChannelSelectMenuBuilder>,\n menu_mentionable: ActionRowBuilder<MentionableSelectMenuBuilder>,\n menu_role: ActionRowBuilder<RoleSelectMenuBuilder>\n};\n\n/**\n * Available Discord.js builder types for use with BuilderComponent\n */\nexport type BuilderType = keyof typeof BuilderTypes;\n\n/**\n * @internal\n */\nexport type InstantiatedBuilder<BuilderKey extends BuilderType> = InstanceType<(typeof BuilderTypes)[BuilderKey]>;\n\n/**\n * Available Discord.js action row types for use with RowComponent\n */\nexport type RowType = keyof typeof RowTypes;\n\n/**\n * @internal\n */\nexport type InstantiatedActionRow<RowKey extends RowType> = InstanceType<(typeof RowTypes)[RowKey]>;\n\n/**\n * Base class for Discord component wrappers\n *\n * Provides common functionality for building Discord components with proper typing.\n *\n * @typeParam TComponent - The Discord.js component type being wrapped\n *\n * @internal\n */\nexport abstract class BaseComponent<TComponent> {\n private readonly _component: TComponent;\n\n protected constructor(ComponentClass: new () => TComponent) {\n this._component = new ComponentClass();\n }\n\n /**\n * Gets the built component (should be considered read-only)\n *\n * Returns the finalized component ready for use in Discord messages.\n *\n * Please do not use for further configuration, use `this.instance` for that.\n * @example new SomeComponent().component\n */\n public abstract get component(): InstantiatedBuilder<BuilderType> | InstantiatedActionRow<RowType>;\n\n /**\n * Gets the component instance for configuration\n *\n * Use this to access Discord.js builder methods like setTitle(), setDescription(), etc.\n *\n * Use this in your component classes to configure the builder\n * @example this.instance.setTitle('My Modal')\n */\n protected get instance(): TComponent {\n return this._component;\n }\n}\n\n/**\n * Base class for Discord.js builder components\n *\n * Wraps Discord.js builders (SlashCommandBuilder, EmbedBuilder, etc.) with\n * Seedcord-specific defaults and helper methods.\n *\n * @typeParam BuilderKey - The type of Discord.js builder being wrapped\n */\nexport abstract class BuilderComponent<BuilderKey extends BuilderType> extends BaseComponent<\n InstantiatedBuilder<BuilderKey>\n> {\n private colorApplied = false;\n\n protected constructor(public readonly type: BuilderKey) {\n const ComponentClass = BuilderTypes[type] as unknown;\n super(ComponentClass as new () => InstantiatedBuilder<BuilderKey>);\n\n if (this.instance instanceof SlashCommandBuilder || this.instance instanceof ContextMenuCommandBuilder) {\n this.instance.setContexts(InteractionContextType.Guild);\n }\n }\n\n get component(): InstantiatedBuilder<BuilderKey> {\n this.applyBotColor();\n return this.instance;\n }\n\n // Resolving in the constructor would capture the default for a component built before setBotColor()\n // ran. The unset check keeps a color the subclass set for itself.\n private applyBotColor(): void {\n if (this.colorApplied) return;\n this.colorApplied = true;\n\n const color = getBotColor();\n if (this.instance instanceof EmbedBuilder) {\n if (this.instance.data.color === undefined) this.instance.setColor(color);\n } else if (this.instance instanceof ContainerBuilder) {\n const accent = this.instance.data.accent_color;\n if (accent === null || accent === undefined) {\n this.instance.setAccentColor(color === 'Default' ? undefined : resolveColor(color));\n }\n }\n }\n}\n\n/**\n * Base class for Discord action row components\n *\n * Wraps Discord.js action row builder with Seedcord-specific defaults and helper methods.\n *\n * @typeParam RowKey - The Discord.js action row type being wrapped\n */\nexport abstract class RowComponent<RowKey extends RowType> extends BaseComponent<InstantiatedActionRow<RowKey>> {\n protected constructor(public readonly type: RowKey) {\n const ComponentClass = RowTypes[type] as unknown;\n super(ComponentClass as new () => InstantiatedActionRow<RowKey>);\n }\n\n get component(): InstantiatedActionRow<RowKey> {\n return this.instance;\n }\n}\n\n/**\n * Pre-configured error embed with default styling\n *\n * This is bundled in {@link CustomError}s as the response.\n *\n * @internal\n */\nexport class BaseErrorEmbed extends BuilderComponent<'embed'> {\n /**\n * Creates a new error embed with default configuration.\n */\n public constructor() {\n super('embed');\n this.instance.setTitle('Cannot Proceed');\n }\n}\n\n/**\n * Base class for custom error types with Discord embed responses\n *\n * Errors extending CustomError should be used with the `Catchable` decorators to implement a control flow. These errors will be caught and handled by the framework to show the user the configured response.\n */\nexport abstract class CustomError extends Error {\n private _emit = false;\n public readonly response = new BaseErrorEmbed().component;\n\n protected constructor(public override message: string) {\n super(message);\n\n Error.captureStackTrace(this, this.constructor);\n }\n\n /**\n * Whether this error should be emitted to logs\n *\n * Controls logging behavior. Errors with emit=true will always be logged,\n * while emit=false errors may be suppressed in production.\n *\n * @returns True if the error should be logged\n */\n public get emit(): boolean {\n return this._emit;\n }\n\n /**\n * Sets whether this error should be emitted to logs\n */\n public set emit(value: boolean) {\n this._emit = value;\n }\n}\n","import { CustomError } from '@interfaces/Components';\n\nimport type { UUID } from 'crypto';\n\n/**\n * Generic database operation error with UUID tracking.\n *\n * Thrown for various database operation failures and includes\n * a UUID for error tracking and debugging purposes.\n *\n * @internal\n */\nexport class DatabaseError extends CustomError {\n /**\n * Creates a new DatabaseError.\n *\n * @param message - The error message describing what went wrong\n * @param uuid - A unique identifier for this specific error instance\n */\n constructor(\n message: string,\n public uuid: UUID\n ) {\n super(message);\n this.emit = true; // Emit in logs regardless of environment\n this.name = 'DatabaseError';\n\n this.response\n .setTitle('Database Error')\n .setDescription(`An error occurred while interacting with the database.\\n### UUID: \\`${this.uuid}\\``);\n }\n}\n"],"mappings":";;;AAGA,MAAM,gBAAiC;AAEvC,IAAI,UAA2B;;AAG/B,SAAgB,YAAY,OAA0C;CAClE,UAAU,SAAS;AACvB;;AAGA,SAAgB,cAA+B;CAC3C,OAAO;AACX;;;;;;;;;ACyBA,MAAa,eAAe;CAExB,SAASA;CACT,cAAcC;CACd,YAAYC;CACZ,OAAOC;CAGP,OAAOC;CAGP,OAAOC;CACP,OAAOC;CACP,YAAYC;CACZ,aAAaC;CACb,UAAUC;CACV,gBAAgBC;CAChB,uBAAuBC;CACvB,aAAaC;CACb,oBAAoBC;CAGpB,QAAQC;CACR,aAAaC;CACb,oBAAoBC;CACpB,WAAWC;CACX,cAAcC;CACd,kBAAkBC;CAClB,WAAWC;CAGX,WAAWC;CACX,cAAcC;CACd,MAAMC;CACN,OAAOC;CACP,SAASC;CACT,WAAWC;AACf;;;;;;AAOA,MAAa,WAOT;CACA,QAAQC;CACR,aAAaA;CACb,WAAWA;CACX,cAAcA;CACd,kBAAkBA;CAClB,WAAWA;AACf;;;;;;;;;;AA+BA,IAAsB,gBAAtB,MAAgD;CAC5C,AAAiB;CAEjB,AAAU,YAAY,gBAAsC;EACxD,KAAK,aAAa,IAAI,eAAe;CACzC;;;;;;;;;CAoBA,IAAc,WAAuB;EACjC,OAAO,KAAK;CAChB;AACJ;;;;;;;;;AAUA,IAAsB,mBAAtB,cAA+E,cAE7E;CAGwC;CAFtC,AAAQ,eAAe;CAEvB,AAAU,YAAY,AAAgB,MAAkB;EACpD,MAAM,iBAAiB,aAAa;EACpC,MAAM,cAA2D;EAF/B;EAIlC,IAAI,KAAK,oBAAoB3B,kCAAuB,KAAK,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