@mostfeatured/dbi 0.2.16 → 0.2.18

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.
Files changed (81) hide show
  1. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +4 -0
  2. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -1
  3. package/dist/src/types/Components/HTMLComponentsV2/index.js +40 -5
  4. package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -1
  5. package/dist/src/types/Event.d.ts +21 -13
  6. package/dist/src/types/Event.d.ts.map +1 -1
  7. package/dist/src/types/Event.js.map +1 -1
  8. package/dist/test/index.js +1 -1
  9. package/dist/test/index.js.map +1 -1
  10. package/generated/namespaceData.d.ts +3 -1
  11. package/package.json +6 -2
  12. package/.gitattributes +0 -2
  13. package/.hintrc +0 -8
  14. package/.vscode/settings.json +0 -3
  15. package/docs/ADVANCED_FEATURES.md +0 -840
  16. package/docs/API_REFERENCE.md +0 -929
  17. package/docs/CHAT_INPUT.md +0 -811
  18. package/docs/COMPONENTS.md +0 -1039
  19. package/docs/EVENTS.md +0 -568
  20. package/docs/GETTING_STARTED.md +0 -398
  21. package/docs/LOCALIZATION.md +0 -777
  22. package/docs/README.md +0 -345
  23. package/docs/SVELTE_COMPONENTS.md +0 -1111
  24. package/docs/llm/ADVANCED_FEATURES.txt +0 -521
  25. package/docs/llm/API_REFERENCE.txt +0 -659
  26. package/docs/llm/CHAT_INPUT.txt +0 -514
  27. package/docs/llm/COMPONENTS.txt +0 -595
  28. package/docs/llm/EVENTS.txt +0 -449
  29. package/docs/llm/GETTING_STARTED.txt +0 -296
  30. package/docs/llm/LOCALIZATION.txt +0 -501
  31. package/docs/llm/README.txt +0 -193
  32. package/docs/llm/SVELTE_COMPONENTS.txt +0 -566
  33. package/src/DBI.ts +0 -1007
  34. package/src/Events.ts +0 -189
  35. package/src/data/eventMap.json +0 -248
  36. package/src/index.ts +0 -23
  37. package/src/methods/handleMessageCommands.ts +0 -482
  38. package/src/methods/hookEventListeners.ts +0 -119
  39. package/src/methods/hookInteractionListeners.ts +0 -314
  40. package/src/methods/publishInteractions.ts +0 -256
  41. package/src/types/ApplicationRoleConnectionMetadata.ts +0 -19
  42. package/src/types/Builders/ButtonBuilder.ts +0 -53
  43. package/src/types/Builders/ChannelSelectMenuBuilder.ts +0 -53
  44. package/src/types/Builders/MentionableSelectMenuBuilder.ts +0 -53
  45. package/src/types/Builders/ModalBuilder.ts +0 -53
  46. package/src/types/Builders/RoleSelectMenuBuilder.ts +0 -53
  47. package/src/types/Builders/StringSelectMenuBuilder.ts +0 -53
  48. package/src/types/Builders/UserSelectMenuBuilder.ts +0 -53
  49. package/src/types/ChatInput/ChatInput.ts +0 -28
  50. package/src/types/ChatInput/ChatInputOptions.ts +0 -388
  51. package/src/types/Components/Button.ts +0 -39
  52. package/src/types/Components/ChannelSelectMenu.ts +0 -43
  53. package/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.ts +0 -78
  54. package/src/types/Components/HTMLComponentsV2/index.ts +0 -761
  55. package/src/types/Components/HTMLComponentsV2/parser.ts +0 -649
  56. package/src/types/Components/HTMLComponentsV2/svelteParser.ts +0 -1503
  57. package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +0 -416
  58. package/src/types/Components/MentionableSelectMenu.ts +0 -43
  59. package/src/types/Components/Modal.ts +0 -46
  60. package/src/types/Components/RoleSelectMenu.ts +0 -43
  61. package/src/types/Components/StringSelectMenu.ts +0 -43
  62. package/src/types/Components/UserSelectMenu.ts +0 -43
  63. package/src/types/Event.ts +0 -145
  64. package/src/types/Interaction.ts +0 -100
  65. package/src/types/other/CustomEvent.ts +0 -19
  66. package/src/types/other/FakeMessageInteraction.ts +0 -408
  67. package/src/types/other/InteractionLocale.ts +0 -34
  68. package/src/types/other/Locale.ts +0 -70
  69. package/src/types/other/MessageContextMenu.ts +0 -27
  70. package/src/types/other/UserContextMenu.ts +0 -25
  71. package/src/utils/MemoryStore.ts +0 -28
  72. package/src/utils/UtilTypes.ts +0 -11
  73. package/src/utils/customId.ts +0 -49
  74. package/src/utils/permissions.ts +0 -5
  75. package/src/utils/recursiveImport.ts +0 -35
  76. package/src/utils/recursiveUnload.ts +0 -25
  77. package/src/utils/unloadModule.ts +0 -7
  78. package/test/index.ts +0 -176
  79. package/test/product-showcase.svelte +0 -558
  80. package/test/test.ts +0 -3
  81. package/tsconfig.json +0 -51
@@ -1,416 +0,0 @@
1
- import { compile } from "svelte/compiler";
2
- import { DBI } from "../../../DBI";
3
- import { NamespaceEnums } from "../../../../generated/namespaceData";
4
- import { parseHTMLComponentsV2, parseHTMLComponentsV2Multi } from "./parser";
5
- import { parseSvelteComponent, createHandlerContext, SvelteComponentInfo, HandlerContextResult, validateSvelteComponent, logValidationWarnings } from "./svelteParser";
6
- import * as stuffs from "stuffs";
7
- import * as vm from "vm";
8
-
9
- export interface SvelteRenderOptions {
10
- data?: Record<string, any>;
11
- ttl?: number;
12
- /** If true, skips validation warnings (useful for production) */
13
- skipValidation?: boolean;
14
- /** The file path of the Svelte component (used for resolving relative imports) */
15
- filePath?: string;
16
- }
17
-
18
- export interface ModalDefinition {
19
- title: string;
20
- customId: string;
21
- components: any[];
22
- modalId: string;
23
- }
24
-
25
- export interface SvelteRenderResult {
26
- components: any[];
27
- handlers: Map<string, { handlerFn: Function, context: any }>;
28
- componentInfo: SvelteComponentInfo;
29
- /** Modal definitions parsed from <components type="modal"> elements */
30
- modals: Map<string, ModalDefinition>;
31
- }
32
-
33
- /**
34
- * Compile and render a Svelte component to Discord components
35
- */
36
- export async function renderSvelteComponent(
37
- dbi: DBI<NamespaceEnums>,
38
- source: string,
39
- dbiName: string,
40
- options: SvelteRenderOptions = {}
41
- ): Promise<SvelteRenderResult> {
42
- const { data = {}, ttl = 0, skipValidation = false, filePath } = options;
43
-
44
- // Parse the Svelte component to extract handlers
45
- // This also injects auto-generated names into elements without name attribute
46
- const componentInfo = await parseSvelteComponent(source, data);
47
-
48
- // Validate the component and log warnings (only on first render, not re-renders)
49
- if (!skipValidation && !data.$ref) {
50
- const warnings = validateSvelteComponent(componentInfo, data, dbiName);
51
- if (warnings.length > 0) {
52
- logValidationWarnings(warnings);
53
- }
54
- }
55
-
56
- // Use the processed source (with auto-generated names injected)
57
- const processedSource = componentInfo.processedSource;
58
-
59
- // Compile the Svelte component for SSR (Svelte 5)
60
- let compiled;
61
- try {
62
- compiled = compile(processedSource, {
63
- generate: "server",
64
- css: "injected",
65
- dev: false,
66
- } as any);
67
- } catch (compileError: any) {
68
- // Format Svelte compile error with helpful details
69
- const errorMessage = compileError.message || 'Unknown compile error';
70
- const location = compileError.start || compileError.loc || compileError.position;
71
- let details = errorMessage;
72
-
73
- if (location) {
74
- const lines = processedSource.split('\n');
75
- const lineNum = location.line || 1;
76
- const column = location.column || 0;
77
- const errorLine = lines[lineNum - 1] || '';
78
- const prevLine = lines[lineNum - 2] || '';
79
- const nextLine = lines[lineNum] || '';
80
-
81
- details = `
82
- Svelte Compile Error at line ${lineNum}, column ${column}:
83
- ${errorMessage}
84
-
85
- ${lineNum > 1 ? `${lineNum - 1} | ${prevLine}\n` : ''}${lineNum} | ${errorLine}
86
- ${' '.repeat(String(lineNum).length + 3 + column)}^
87
- ${nextLine ? `${lineNum + 1} | ${nextLine}` : ''}
88
- `.trim();
89
- }
90
-
91
- // Check for common mistakes and add hints
92
- let hint = '';
93
- if (errorMessage.includes('Unexpected token')) {
94
- hint = '\n\n💡 Hint: Check for missing closing tags, unclosed braces, or invalid JavaScript syntax.';
95
- } else if (errorMessage.includes('is not defined')) {
96
- hint = '\n\n💡 Hint: Make sure all variables are declared in $props() or as local variables.';
97
- } else if (errorMessage.includes('Expected')) {
98
- hint = '\n\n💡 Hint: There might be a syntax error in your template or script.';
99
- }
100
-
101
- const enhancedError = new Error(`[DBI-Svelte] Failed to compile component "${dbiName}":\n${details}${hint}`);
102
- (enhancedError as any).originalError = compileError;
103
- (enhancedError as any).type = 'svelte-compile-error';
104
- throw enhancedError;
105
- }
106
-
107
- // Create a module context for the compiled code
108
- let html = "";
109
- try {
110
- const moduleContext = createModuleContext(dbi, data, ttl);
111
- const Component = evaluateCompiledComponent(compiled.js.code, moduleContext, filePath);
112
-
113
- // Svelte 5 SSR: Use render from svelte/server
114
- const { render } = require("svelte/server");
115
- // Pass data properties as top-level props (Svelte 5 expects flat props object)
116
- const renderResult = render(Component, { props: data });
117
- html = renderResult.body || "";
118
- } catch (runtimeError: any) {
119
- // Format runtime error with helpful details
120
- const errorMessage = runtimeError.message || 'Unknown runtime error';
121
- let hint = '';
122
-
123
- if (errorMessage.includes('is not a function')) {
124
- hint = '\n\n💡 Hint: A function you are trying to call is undefined. Check handler names.';
125
- } else if (errorMessage.includes('Cannot read properties of undefined') || errorMessage.includes('undefined is not an object')) {
126
- hint = '\n\n💡 Hint: You are trying to access a property of an undefined value. Check your data object.';
127
- } else if (errorMessage.includes('is not defined')) {
128
- hint = '\n\n💡 Hint: A variable is used but not declared. Make sure it is in $props() or declared locally.';
129
- }
130
-
131
- const enhancedError = new Error(`[DBI-Svelte] Runtime error in component "${dbiName}":\n${errorMessage}${hint}`);
132
- (enhancedError as any).originalError = runtimeError;
133
- (enhancedError as any).type = 'svelte-runtime-error';
134
- throw enhancedError;
135
- }
136
-
137
- // For Svelte mode, inject state into interactive elements as a ref
138
- // Reuse existing ref if data already has one, otherwise create new
139
- if (data && Object.keys(data).length > 0) {
140
- let stateRefId: string;
141
-
142
- // Check if data already has a $ref (from previous render)
143
- if (data.$ref && typeof data.$ref === 'string') {
144
- stateRefId = data.$ref;
145
- // Update the existing ref's value with new data
146
- const existingRef = dbi.data.refs.get(stateRefId);
147
- if (existingRef) {
148
- existingRef.value = data;
149
- existingRef.at = Date.now(); // Refresh timestamp
150
- } else {
151
- // Ref expired or was deleted, create new one with same ID
152
- dbi.data.refs.set(stateRefId, { at: Date.now(), value: data, ttl });
153
- }
154
- } else {
155
- // Create a new ref for the state
156
- stateRefId = stuffs.randomString(8);
157
- data.$ref = stateRefId; // Store ref ID in data for future updates
158
- dbi.data.refs.set(stateRefId, { at: Date.now(), value: data, ttl });
159
- }
160
-
161
- // Add state ref to all elements with name attribute (buttons, selects)
162
- // This includes both manual names and auto-generated names from svelteParser
163
- html = html.replace(/<button([^>]*name="[^"]*"[^>]*)>/g, (match, attrs) => {
164
- // Check if it already has data attributes
165
- if (attrs.includes('data-1:')) return match;
166
- return `<button${attrs} data-1:ref="${stateRefId}">`;
167
- });
168
- // Also handle select elements (with optional -menu suffix for Svelte compatibility)
169
- // Supports: string-select, user-select, role-select, channel-select, mentionable-select
170
- // Both with and without -menu suffix (e.g., string-select-menu or string-select)
171
- html = html.replace(/<(string-select(?:-menu)?|user-select(?:-menu)?|role-select(?:-menu)?|channel-select(?:-menu)?|mentionable-select(?:-menu)?)([^>]*name="[^"]*"[^>]*)>/g, (match, tag, attrs) => {
172
- if (attrs.includes('data-1:')) return match;
173
- return `<${tag}${attrs} data-1:ref="${stateRefId}">`;
174
- });
175
- // Handle modal elements with name attribute
176
- html = html.replace(/<modal([^>]*name="[^"]*"[^>]*)>/g, (match, attrs) => {
177
- if (attrs.includes('data-1:')) return match;
178
- return `<modal${attrs} data-1:ref="${stateRefId}">`;
179
- });
180
- }
181
-
182
- // Parse the rendered HTML to Discord components (with modal support)
183
- const parseResult = parseHTMLComponentsV2Multi(dbi, html, dbiName, { data, ttl });
184
- const components = parseResult.components;
185
- const modals = parseResult.modals;
186
-
187
- // Get source directory for resolving relative imports
188
- const path = require("path");
189
- const sourceDir = filePath ? path.dirname(path.resolve(filePath)) : undefined;
190
-
191
- // Create handler context (also captures $effect callbacks)
192
- const handlerContext = createHandlerContext(componentInfo.scriptContent, data, undefined, undefined, sourceDir);
193
- const handlers = new Map<string, { handlerFn: Function, context: any }>();
194
-
195
- // Run effects on initial render
196
- handlerContext.runEffects();
197
-
198
- // Map handlers to component names
199
- componentInfo.handlers.forEach((handlerInfo, componentName) => {
200
- const handlerFn = handlerContext.handlers[handlerInfo.handlerName];
201
- if (handlerFn && typeof handlerFn === "function") {
202
- handlers.set(componentName, {
203
- handlerFn,
204
- context: data
205
- });
206
- }
207
- });
208
-
209
- return {
210
- components,
211
- handlers,
212
- componentInfo,
213
- modals
214
- };
215
- }
216
-
217
- /**
218
- * Create a module context for evaluating the compiled Svelte component
219
- */
220
- function createModuleContext(dbi: DBI<NamespaceEnums>, data: Record<string, any>, ttl: number) {
221
- return {
222
- // Store objects in refs for later retrieval in handlers
223
- // This is used internally by the parser when converting to Discord components
224
- __storeRef: (obj: any) => {
225
- let id = stuffs.randomString(8);
226
- dbi.data.refs.set(id, { at: Date.now(), value: obj, ttl });
227
- return id;
228
- },
229
-
230
- // DBI instance for advanced usage
231
- __dbi: dbi,
232
-
233
- // All data context available
234
- ...data,
235
- data, // Also expose as 'data' prop
236
- };
237
- }
238
-
239
- /**
240
- * Evaluate the compiled Svelte component code
241
- */
242
- function evaluateCompiledComponent(code: string, context: Record<string, any>, filePath?: string): any {
243
- try {
244
- // Load Svelte 5 internal runtime
245
- const svelteInternal = require("svelte/internal/server");
246
- const path = require("path");
247
-
248
- // Get the directory of the source file for resolving relative imports
249
- const sourceDir = filePath ? path.dirname(path.resolve(filePath)) : process.cwd();
250
-
251
- // Process the code to work in our context
252
- let processedCode = code;
253
-
254
- // Collect external modules to inject into sandbox
255
- const externalModules: Record<string, any> = {};
256
-
257
- // Replace svelte internal imports
258
- processedCode = processedCode.replace(
259
- /import\s*\*\s*as\s*(\w+)\s*from\s*["']svelte\/internal\/server["'];?/g,
260
- 'const $1 = __svelteInternal;'
261
- );
262
- processedCode = processedCode.replace(
263
- /import\s*\{([^}]+)\}\s*from\s*["']svelte\/internal\/server["'];?/g,
264
- (match, imports) => {
265
- const importList = imports.split(',').map((i: string) => i.trim());
266
- return `const { ${importList.join(', ')} } = __svelteInternal;`;
267
- }
268
- );
269
-
270
- // Handle external module imports (default imports)
271
- processedCode = processedCode.replace(
272
- /import\s+(\w+)\s+from\s*["']([^"']+)["'];?/g,
273
- (match, varName, modulePath) => {
274
- // Skip svelte imports
275
- if (modulePath.startsWith('svelte')) return '';
276
- try {
277
- // Resolve relative paths from source file directory
278
- const resolvedPath = modulePath.startsWith('.')
279
- ? path.resolve(sourceDir, modulePath)
280
- : modulePath;
281
- const mod = require(resolvedPath);
282
- externalModules[varName] = mod.default || mod;
283
- return `const ${varName} = __externalModules.${varName};`;
284
- } catch (e) {
285
- return '';
286
- }
287
- }
288
- );
289
-
290
- // Handle named imports from external modules
291
- processedCode = processedCode.replace(
292
- /import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["'];?/g,
293
- (match, imports, modulePath) => {
294
- // Skip svelte imports
295
- if (modulePath.startsWith('svelte')) return '';
296
- try {
297
- // Resolve relative paths from source file directory
298
- const resolvedPath = modulePath.startsWith('.')
299
- ? path.resolve(sourceDir, modulePath)
300
- : modulePath;
301
- const mod = require(resolvedPath);
302
- const importList = imports.split(',').map((i: string) => i.trim());
303
- importList.forEach((importName: string) => {
304
- const [name, alias] = importName.split(' as ').map(s => s.trim());
305
- externalModules[alias || name] = mod[name] || mod.default?.[name];
306
- });
307
- return importList.map((importName: string) => {
308
- const [name, alias] = importName.split(' as ').map(s => s.trim());
309
- return `const ${alias || name} = __externalModules.${alias || name};`;
310
- }).join('\n');
311
- } catch (e) {
312
- return '';
313
- }
314
- }
315
- );
316
-
317
- // Handle namespace imports from external modules
318
- processedCode = processedCode.replace(
319
- /import\s*\*\s*as\s*(\w+)\s*from\s*["']([^"']+)["'];?/g,
320
- (match, varName, modulePath) => {
321
- // Skip svelte imports
322
- if (modulePath.startsWith('svelte')) return '';
323
- try {
324
- // Resolve relative paths from source file directory
325
- const resolvedPath = modulePath.startsWith('.')
326
- ? path.resolve(sourceDir, modulePath)
327
- : modulePath;
328
- const mod = require(resolvedPath);
329
- externalModules[varName] = mod;
330
- return `const ${varName} = __externalModules.${varName};`;
331
- } catch (e) {
332
- return '';
333
- }
334
- }
335
- );
336
-
337
- // Remove any remaining import statements
338
- processedCode = processedCode
339
- .split('\n')
340
- .filter(line => !line.trim().startsWith('import '))
341
- .join('\n');
342
-
343
- // Replace 'export default' with assignment
344
- processedCode = processedCode.replace(/export\s+default\s+/g, '__exports.default = ');
345
- // Replace 'export function' with assignment
346
- processedCode = processedCode.replace(/export\s+function\s+(\w+)/g, '__exports.$1 = function $1');
347
- // Replace 'export const' with assignment
348
- processedCode = processedCode.replace(/export\s+const\s+(\w+)/g, '__exports.$1 = ');
349
- // Replace 'export let' with assignment
350
- processedCode = processedCode.replace(/export\s+let\s+(\w+)/g, '__exports.$1 = ');
351
-
352
- // Create the sandbox context
353
- const __exports: any = {};
354
- // Svelte lifecycle functions - no-ops for SSR
355
- const svelteLifecycle = {
356
- onMount: () => () => { }, // Returns cleanup function
357
- onDestroy: () => { },
358
- beforeUpdate: () => { },
359
- afterUpdate: () => { },
360
- tick: () => Promise.resolve(),
361
- untrack: (fn: () => any) => fn(),
362
- createEventDispatcher: () => () => { },
363
- };
364
-
365
- // Note: Svelte 5 runes ($state, $derived, etc.) are compile-time features
366
- // The compiler transforms them, so we don't need runtime implementations.
367
- // The `$` variable is used by compiled code as the svelte/internal/server namespace.
368
-
369
- const sandbox = {
370
- __svelteInternal: svelteInternal,
371
- __externalModules: externalModules,
372
- $: svelteInternal, // Direct alias for compiled Svelte code that uses `$`
373
- __exports,
374
- console,
375
- ...svelteLifecycle,
376
- ...context,
377
- };
378
-
379
- // Wrap code in IIFE
380
- const wrappedCode = `
381
- (function() {
382
- ${processedCode}
383
- })();
384
- `;
385
-
386
- // Run in VM context for better isolation
387
- vm.createContext(sandbox);
388
- vm.runInContext(wrappedCode, sandbox);
389
-
390
- // Return the component
391
- const Component = sandbox.__exports.default;
392
-
393
- if (!Component) {
394
- throw new Error("Svelte component did not export a default component");
395
- }
396
-
397
- return Component;
398
- } catch (error) {
399
- throw error;
400
- }
401
- }
402
-
403
- /**
404
- * Render a Svelte component from a file
405
- */
406
- export async function renderSvelteComponentFromFile(
407
- dbi: DBI<NamespaceEnums>,
408
- filePath: string,
409
- dbiName: string,
410
- options: SvelteRenderOptions = {}
411
- ): Promise<SvelteRenderResult> {
412
- const fs = require("fs");
413
- const source = fs.readFileSync(filePath, "utf-8");
414
- // Pass filePath to options for resolving relative imports
415
- return await renderSvelteComponent(dbi, source, dbiName, { ...options, filePath });
416
- }
@@ -1,43 +0,0 @@
1
- import Discord from "discord.js";
2
- import { DBI } from "../../DBI";
3
- import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "../Interaction";
4
- import { buildCustomId } from "../../utils/customId";
5
- import { IDBIToJSONArgs } from "../../utils/UtilTypes";
6
- import { NamespaceEnums } from "../../../generated/namespaceData";
7
- import stuffs from "stuffs";
8
- import { DBIMentionableSelectMenuBuilder, DBIMentionableSelectMenuOverrides } from "../Builders/MentionableSelectMenuBuilder";
9
-
10
- export interface IDBIMentionableSelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
11
- interaction: Discord.MentionableSelectMenuInteraction<"cached">;
12
- data: TDBIReferencedData[];
13
- }
14
-
15
- export type TDBIMentionableSelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBIMentionableSelectMenu<TNamespace>, "type" | "description" | "dbi" | "toJSON" | "createBuilder" | "at">;
16
-
17
- export type SelectMenuDefaultOptions = Omit<Discord.MentionableSelectMenuComponentData, "customId" | "type" | "options">;
18
-
19
- export class DBIMentionableSelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
20
- constructor(dbi: DBI<TNamespace>, args: TDBIMentionableSelectMenuOmitted<TNamespace>) {
21
- super(dbi, {
22
- ...(args as any),
23
- type: "MentionableSelectMenu",
24
- });
25
- }
26
-
27
- declare options?: SelectMenuDefaultOptions;
28
-
29
- override onExecute(ctx: IDBIMentionableSelectMenuExecuteCtx<TNamespace>) { };
30
-
31
- override toJSON(arg: IDBIToJSONArgs<DBIMentionableSelectMenuOverrides> = {}): Discord.MentionableSelectMenuComponentData {
32
- return {
33
- ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
34
- customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
35
- type: Discord.ComponentType.MentionableSelect,
36
- } as any;
37
- };
38
-
39
- createBuilder(arg: IDBIToJSONArgs<DBIMentionableSelectMenuOverrides> = {}): DBIMentionableSelectMenuBuilder<TNamespace> {
40
- return new DBIMentionableSelectMenuBuilder({ component: this, ...arg })
41
- }
42
-
43
- }
@@ -1,46 +0,0 @@
1
- import { DBI } from "../../DBI";
2
- import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "../Interaction";
3
- import Discord from "discord.js";
4
- import { buildCustomId } from "../../utils/customId";
5
- import { IDBIToJSONArgs } from "../../utils/UtilTypes";
6
- import { NamespaceEnums } from "../../../generated/namespaceData";
7
- import stuffs from "stuffs";
8
- import { DBIModalBuilder, DBIModalOverrides } from "../Builders/ModalBuilder";
9
-
10
-
11
- export interface IDBIModalExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
12
- interaction: Discord.ModalSubmitInteraction<"cached">;
13
- data: TDBIReferencedData[];
14
- }
15
-
16
- export interface ModalComponentData {
17
- title: string;
18
- components: (Discord.ActionRowData<Discord.ModalActionRowComponentData>)[];
19
- }
20
-
21
- export type TDBIModalOmitted<TNamespace extends NamespaceEnums> = Omit<DBIModal<TNamespace>, "type" | "description" | "dbi" | "toJSON" | "createBuilder" | "at">;
22
-
23
- export class DBIModal<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
24
- constructor(dbi: DBI<TNamespace>, args: TDBIModalOmitted<TNamespace>) {
25
- super(dbi, {
26
- ...(args as any),
27
- type: "Modal"
28
- });
29
- }
30
-
31
- declare options?: ModalComponentData;
32
-
33
- override onExecute(ctx: IDBIModalExecuteCtx<TNamespace>) { };
34
-
35
- override toJSON(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): Discord.ModalComponentData {
36
- return {
37
- ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
38
- customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl)
39
- } as any;
40
- };
41
-
42
- createBuilder(arg: IDBIToJSONArgs<DBIModalOverrides> = {}): DBIModalBuilder<TNamespace> {
43
- return new DBIModalBuilder({ component: this, ...arg })
44
- }
45
-
46
- }
@@ -1,43 +0,0 @@
1
- import Discord from "discord.js";
2
- import { DBI } from "../../DBI";
3
- import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "../Interaction";
4
- import { buildCustomId } from "../../utils/customId";
5
- import { IDBIToJSONArgs } from "../../utils/UtilTypes";
6
- import { NamespaceEnums } from "../../../generated/namespaceData";
7
- import stuffs from "stuffs";
8
- import { DBIRoleSelectMenuBuilder, DBIRoleSelectMenuOverrides } from "../Builders/RoleSelectMenuBuilder";
9
-
10
- export interface IDBIRoleSelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
11
- interaction: Discord.RoleSelectMenuInteraction<"cached">;
12
- data: TDBIReferencedData[];
13
- }
14
-
15
- export type TDBIRoleSelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBIRoleSelectMenu<TNamespace>, "type" | "description" | "dbi" | "toJSON" | "createBuilder" | "at">;
16
-
17
- export type SelectMenuDefaultOptions = Omit<Discord.RoleSelectMenuComponentData, "customId" | "type" | "options">;
18
-
19
- export class DBIRoleSelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
20
- constructor(dbi: DBI<TNamespace>, args: TDBIRoleSelectMenuOmitted<TNamespace>) {
21
- super(dbi, {
22
- ...(args as any),
23
- type: "RoleSelectMenu",
24
- });
25
- }
26
-
27
- declare options?: SelectMenuDefaultOptions;
28
-
29
- override onExecute(ctx: IDBIRoleSelectMenuExecuteCtx<TNamespace>) { };
30
-
31
- override toJSON(arg: IDBIToJSONArgs<DBIRoleSelectMenuOverrides> = {}): Discord.RoleSelectMenuComponentData {
32
- return {
33
- ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
34
- customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
35
- type: Discord.ComponentType.RoleSelect,
36
- } as any;
37
- };
38
-
39
- createBuilder(arg: IDBIToJSONArgs<DBIRoleSelectMenuOverrides> = {}): DBIRoleSelectMenuBuilder<TNamespace> {
40
- return new DBIRoleSelectMenuBuilder({ component: this, ...arg })
41
- }
42
-
43
- }
@@ -1,43 +0,0 @@
1
- import Discord from "discord.js";
2
- import { DBI } from "../../DBI";
3
- import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "../Interaction";
4
- import { buildCustomId } from "../../utils/customId";
5
- import { IDBIToJSONArgs } from "../../utils/UtilTypes";
6
- import { NamespaceEnums } from "../../../generated/namespaceData";
7
- import stuffs from "stuffs";
8
- import { DBIStringSelectMenuBuilder, DBIStringSelectMenuOverrides } from "../Builders/StringSelectMenuBuilder";
9
-
10
- export interface IDBIStringSelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
11
- interaction: Discord.StringSelectMenuInteraction<"cached">;
12
- data: TDBIReferencedData[];
13
- }
14
-
15
- export type TDBIStringSelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBIStringSelectMenu<TNamespace>, "type" | "description" | "dbi" | "toJSON" | "createBuilder" | "at">;
16
-
17
- export type SelectMenuDefaultOptions = Required<Pick<Discord.StringSelectMenuComponentData, "options">> & Omit<Discord.StringSelectMenuComponentData, "customId" | "type" | "options">;
18
-
19
- export class DBIStringSelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
20
- constructor(dbi: DBI<TNamespace>, args: TDBIStringSelectMenuOmitted<TNamespace>) {
21
- super(dbi, {
22
- ...(args as any),
23
- type: "StringSelectMenu",
24
- });
25
- }
26
-
27
- declare options?: SelectMenuDefaultOptions;
28
-
29
- override onExecute(ctx: IDBIStringSelectMenuExecuteCtx<TNamespace>) { };
30
-
31
- override toJSON(arg: IDBIToJSONArgs<DBIStringSelectMenuOverrides> = {}): Discord.StringSelectMenuComponentData {
32
- return {
33
- ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
34
- customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
35
- type: Discord.ComponentType.StringSelect,
36
- } as any;
37
- };
38
-
39
- createBuilder(arg: IDBIToJSONArgs<DBIStringSelectMenuOverrides> = {}): DBIStringSelectMenuBuilder<TNamespace> {
40
- return new DBIStringSelectMenuBuilder({ component: this, ...arg })
41
- }
42
-
43
- }
@@ -1,43 +0,0 @@
1
- import Discord from "discord.js";
2
- import { DBI } from "../../DBI";
3
- import { DBIBaseInteraction, IDBIBaseExecuteCtx, TDBIReferencedData } from "../Interaction";
4
- import { buildCustomId } from "../../utils/customId";
5
- import { IDBIToJSONArgs } from "../../utils/UtilTypes";
6
- import { NamespaceEnums } from "../../../generated/namespaceData";
7
- import stuffs from "stuffs";
8
- import { DBIUserSelectMenuBuilder, DBIUserSelectMenuOverrides } from "../Builders/UserSelectMenuBuilder";
9
-
10
- export interface IDBIUserSelectMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
11
- interaction: Discord.UserSelectMenuInteraction<"cached">;
12
- data: TDBIReferencedData[];
13
- }
14
-
15
- export type TDBIUserSelectMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBIUserSelectMenu<TNamespace>, "type" | "description" | "dbi" | "toJSON" | "createBuilder" | "at">;
16
-
17
- export type SelectMenuDefaultOptions = Omit<Discord.UserSelectMenuComponentData, "customId" | "type" | "options">;
18
-
19
- export class DBIUserSelectMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
20
- constructor(dbi: DBI<TNamespace>, args: TDBIUserSelectMenuOmitted<TNamespace>) {
21
- super(dbi, {
22
- ...(args as any),
23
- type: "UserSelectMenu",
24
- });
25
- }
26
-
27
- declare options?: SelectMenuDefaultOptions;
28
-
29
- override onExecute(ctx: IDBIUserSelectMenuExecuteCtx<TNamespace>) { };
30
-
31
- override toJSON(arg: IDBIToJSONArgs<DBIUserSelectMenuOverrides> = {}): Discord.UserSelectMenuComponentData {
32
- return {
33
- ...stuffs.defaultify((arg?.overrides || {}), this.options || {}, true),
34
- customId: buildCustomId(this.dbi as any, this.name, arg?.reference?.data || [], arg?.reference?.ttl),
35
- type: Discord.ComponentType.UserSelect,
36
- } as any;
37
- };
38
-
39
- createBuilder(arg: IDBIToJSONArgs<DBIUserSelectMenuOverrides> = {}): DBIUserSelectMenuBuilder<TNamespace> {
40
- return new DBIUserSelectMenuBuilder({ component: this, ...arg })
41
- }
42
-
43
- }