@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.
- package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +4 -0
- package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/index.js +40 -5
- package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -1
- package/dist/src/types/Event.d.ts +21 -13
- package/dist/src/types/Event.d.ts.map +1 -1
- package/dist/src/types/Event.js.map +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test/index.js.map +1 -1
- package/generated/namespaceData.d.ts +3 -1
- package/package.json +6 -2
- package/.gitattributes +0 -2
- package/.hintrc +0 -8
- package/.vscode/settings.json +0 -3
- package/docs/ADVANCED_FEATURES.md +0 -840
- package/docs/API_REFERENCE.md +0 -929
- package/docs/CHAT_INPUT.md +0 -811
- package/docs/COMPONENTS.md +0 -1039
- package/docs/EVENTS.md +0 -568
- package/docs/GETTING_STARTED.md +0 -398
- package/docs/LOCALIZATION.md +0 -777
- package/docs/README.md +0 -345
- package/docs/SVELTE_COMPONENTS.md +0 -1111
- package/docs/llm/ADVANCED_FEATURES.txt +0 -521
- package/docs/llm/API_REFERENCE.txt +0 -659
- package/docs/llm/CHAT_INPUT.txt +0 -514
- package/docs/llm/COMPONENTS.txt +0 -595
- package/docs/llm/EVENTS.txt +0 -449
- package/docs/llm/GETTING_STARTED.txt +0 -296
- package/docs/llm/LOCALIZATION.txt +0 -501
- package/docs/llm/README.txt +0 -193
- package/docs/llm/SVELTE_COMPONENTS.txt +0 -566
- package/src/DBI.ts +0 -1007
- package/src/Events.ts +0 -189
- package/src/data/eventMap.json +0 -248
- package/src/index.ts +0 -23
- package/src/methods/handleMessageCommands.ts +0 -482
- package/src/methods/hookEventListeners.ts +0 -119
- package/src/methods/hookInteractionListeners.ts +0 -314
- package/src/methods/publishInteractions.ts +0 -256
- package/src/types/ApplicationRoleConnectionMetadata.ts +0 -19
- package/src/types/Builders/ButtonBuilder.ts +0 -53
- package/src/types/Builders/ChannelSelectMenuBuilder.ts +0 -53
- package/src/types/Builders/MentionableSelectMenuBuilder.ts +0 -53
- package/src/types/Builders/ModalBuilder.ts +0 -53
- package/src/types/Builders/RoleSelectMenuBuilder.ts +0 -53
- package/src/types/Builders/StringSelectMenuBuilder.ts +0 -53
- package/src/types/Builders/UserSelectMenuBuilder.ts +0 -53
- package/src/types/ChatInput/ChatInput.ts +0 -28
- package/src/types/ChatInput/ChatInputOptions.ts +0 -388
- package/src/types/Components/Button.ts +0 -39
- package/src/types/Components/ChannelSelectMenu.ts +0 -43
- package/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.ts +0 -78
- package/src/types/Components/HTMLComponentsV2/index.ts +0 -761
- package/src/types/Components/HTMLComponentsV2/parser.ts +0 -649
- package/src/types/Components/HTMLComponentsV2/svelteParser.ts +0 -1503
- package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +0 -416
- package/src/types/Components/MentionableSelectMenu.ts +0 -43
- package/src/types/Components/Modal.ts +0 -46
- package/src/types/Components/RoleSelectMenu.ts +0 -43
- package/src/types/Components/StringSelectMenu.ts +0 -43
- package/src/types/Components/UserSelectMenu.ts +0 -43
- package/src/types/Event.ts +0 -145
- package/src/types/Interaction.ts +0 -100
- package/src/types/other/CustomEvent.ts +0 -19
- package/src/types/other/FakeMessageInteraction.ts +0 -408
- package/src/types/other/InteractionLocale.ts +0 -34
- package/src/types/other/Locale.ts +0 -70
- package/src/types/other/MessageContextMenu.ts +0 -27
- package/src/types/other/UserContextMenu.ts +0 -25
- package/src/utils/MemoryStore.ts +0 -28
- package/src/utils/UtilTypes.ts +0 -11
- package/src/utils/customId.ts +0 -49
- package/src/utils/permissions.ts +0 -5
- package/src/utils/recursiveImport.ts +0 -35
- package/src/utils/recursiveUnload.ts +0 -25
- package/src/utils/unloadModule.ts +0 -7
- package/test/index.ts +0 -176
- package/test/product-showcase.svelte +0 -558
- package/test/test.ts +0 -3
- package/tsconfig.json +0 -51
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { NamespaceEnums } from "../../../generated/namespaceData";
|
|
2
|
-
import { DBI } from "../../DBI";
|
|
3
|
-
import { TDBILocaleString } from "./Locale";
|
|
4
|
-
|
|
5
|
-
export type TDBIInteractionLocaleData = {
|
|
6
|
-
[K in TDBILocaleString]?: {
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
options?: {
|
|
10
|
-
[k: string]: {
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
choices?: {
|
|
14
|
-
[k: string]: string
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type TDBIInteractionLocaleOmitted = Omit<DBIInteractionLocale, "dbi">;
|
|
22
|
-
|
|
23
|
-
export class DBIInteractionLocale {
|
|
24
|
-
name: string;
|
|
25
|
-
data: TDBIInteractionLocaleData;
|
|
26
|
-
dbi: DBI<NamespaceEnums>;
|
|
27
|
-
flag?: string;
|
|
28
|
-
constructor(dbi, cfg: TDBIInteractionLocaleOmitted) {
|
|
29
|
-
this.dbi = dbi;
|
|
30
|
-
this.name = cfg.name;
|
|
31
|
-
this.data = cfg.data;
|
|
32
|
-
this.flag = cfg.flag;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import stuffs from "stuffs";
|
|
2
|
-
import { NamespaceData, NamespaceEnums } from "../../../generated/namespaceData";
|
|
3
|
-
import { DBI } from "../../DBI";
|
|
4
|
-
import _ from "lodash";
|
|
5
|
-
import util from "util";
|
|
6
|
-
|
|
7
|
-
export interface DBILangObject {
|
|
8
|
-
[property: string]: DBILangObject & ((...args: any[]) => string);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface DBILangConstructorObject {
|
|
12
|
-
[property: string]: DBILangConstructorObject | string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type TDBILocaleString = "en" | "bg" | "zh" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ro" | "ru" | "es" | "sv" | "th" | "tr" | "uk" | "vi";
|
|
16
|
-
|
|
17
|
-
export type TDBILocaleConstructor<TNamespace extends NamespaceEnums> = Omit<DBILocale<TNamespace>, "data" | "dbi" | "mergeLocale" | "_data" | "get" | "format"> & { data: DBILangConstructorObject };
|
|
18
|
-
|
|
19
|
-
export class DBILocale<TNamespace extends NamespaceEnums> {
|
|
20
|
-
name: TDBILocaleString;
|
|
21
|
-
data: NamespaceData[TNamespace]["contentLocale"];
|
|
22
|
-
_data: DBILangConstructorObject;
|
|
23
|
-
dbi: DBI<TNamespace, {}>;
|
|
24
|
-
flag?: string
|
|
25
|
-
constructor(dbi: DBI<TNamespace, {}>, cfg: TDBILocaleConstructor<TNamespace>) {
|
|
26
|
-
this.dbi = dbi;
|
|
27
|
-
this.name = cfg.name;
|
|
28
|
-
this.flag = cfg.flag;
|
|
29
|
-
this._data = cfg.data;
|
|
30
|
-
this.data = createInfinitePathProxy((path, ...args) => {
|
|
31
|
-
return this.format(path.join("."), ...args);
|
|
32
|
-
});;
|
|
33
|
-
}
|
|
34
|
-
mergeLocale(locale: DBILocale<TNamespace>): DBILocale<TNamespace> {
|
|
35
|
-
this._data = stuffs.defaultify(locale._data, this._data, true) as any;
|
|
36
|
-
locale._data = this._data;
|
|
37
|
-
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
get(path: string): string | null {
|
|
41
|
-
return _.get(this._data as any, path) as string || null;
|
|
42
|
-
}
|
|
43
|
-
format(path: string, ...args: any[]): string {
|
|
44
|
-
let value = this.get(path);
|
|
45
|
-
if (!value) {
|
|
46
|
-
const defaultLocale = this.dbi.locale(this.dbi.config.defaults.locale.name as any);
|
|
47
|
-
if (!defaultLocale || defaultLocale.name === this.name) return this.dbi.config.defaults.locale.invalidPath({
|
|
48
|
-
locale: this,
|
|
49
|
-
path,
|
|
50
|
-
});
|
|
51
|
-
value = defaultLocale.get(path);
|
|
52
|
-
}
|
|
53
|
-
if (!value) return this.dbi.config.defaults.locale.invalidPath({
|
|
54
|
-
locale: this,
|
|
55
|
-
path,
|
|
56
|
-
});
|
|
57
|
-
return stuffs.mapReplace(value, args.map((t, i) => [new RegExp(`\\{${i}(;[^}]+)?\\}`, "g"), t]));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function createInfinitePathProxy(onApplyPath: (path: string[], ...args: any[]) => string, path: string[] = []): any {
|
|
62
|
-
return new Proxy(() => { }, {
|
|
63
|
-
get(target, key) {
|
|
64
|
-
return createInfinitePathProxy(onApplyPath, [...path, key.toString()]);
|
|
65
|
-
},
|
|
66
|
-
apply(target, thisArg, args) {
|
|
67
|
-
return onApplyPath(path, ...args);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DBI } from "../../DBI";
|
|
2
|
-
import { DBIBaseInteraction, IDBIBaseExecuteCtx } from "../Interaction";
|
|
3
|
-
import Discord from "discord.js";
|
|
4
|
-
import { NamespaceEnums } from "../../../generated/namespaceData";
|
|
5
|
-
|
|
6
|
-
export type TDBIMessageContextMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBIMessageContextMenu<TNamespace>, "type" | "description" | "dbi" | "options" | "toJSON">;
|
|
7
|
-
|
|
8
|
-
export interface IDBIMessageContextMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
|
|
9
|
-
interaction: Discord.MessageContextMenuCommandInteraction<"cached">;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export class DBIMessageContextMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
|
|
14
|
-
constructor(dbi: DBI<TNamespace>, cfg: TDBIMessageContextMenuOmitted<TNamespace>) {
|
|
15
|
-
super(dbi, {
|
|
16
|
-
...(cfg as any),
|
|
17
|
-
type: "MessageContextMenu"
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;
|
|
21
|
-
this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
directMessages?: boolean;
|
|
25
|
-
defaultMemberPermissions?: Discord.PermissionsString[];
|
|
26
|
-
override onExecute(ctx: IDBIMessageContextMenuExecuteCtx<TNamespace>): Promise<void> | void {}
|
|
27
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DBI } from "../../DBI";
|
|
2
|
-
import { DBIBaseInteraction, IDBIBaseExecuteCtx } from "../Interaction";
|
|
3
|
-
import Discord from "discord.js";
|
|
4
|
-
import { NamespaceEnums } from "../../../generated/namespaceData";
|
|
5
|
-
|
|
6
|
-
export type TDBIUserContextMenuOmitted<TNamespace extends NamespaceEnums> = Omit<DBIUserContextMenu<TNamespace>, "type" | "description" | "dbi" | "options" | "toJSON">;
|
|
7
|
-
|
|
8
|
-
export interface IDBIUserContextMenuExecuteCtx<TNamespace extends NamespaceEnums> extends IDBIBaseExecuteCtx<TNamespace> {
|
|
9
|
-
interaction: Discord.UserContextMenuCommandInteraction<"cached">;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class DBIUserContextMenu<TNamespace extends NamespaceEnums> extends DBIBaseInteraction<TNamespace> {
|
|
13
|
-
constructor(dbi: DBI<TNamespace>, cfg: TDBIUserContextMenuOmitted<TNamespace>) {
|
|
14
|
-
super(dbi, {
|
|
15
|
-
...(cfg as any),
|
|
16
|
-
type: "UserContextMenu"
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
this.directMessages = cfg.directMessages ?? dbi.config.defaults.directMessages;
|
|
20
|
-
this.defaultMemberPermissions = cfg.defaultMemberPermissions ?? dbi.config.defaults.defaultMemberPermissions;
|
|
21
|
-
}
|
|
22
|
-
directMessages?: boolean;
|
|
23
|
-
defaultMemberPermissions?: Discord.PermissionsString[];
|
|
24
|
-
override onExecute(ctx: IDBIUserContextMenuExecuteCtx<TNamespace>): Promise<void> | void {}
|
|
25
|
-
}
|
package/src/utils/MemoryStore.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
2
|
-
|
|
3
|
-
export class MemoryStore {
|
|
4
|
-
store: Record<string, any>;
|
|
5
|
-
constructor() {
|
|
6
|
-
this.store = {};
|
|
7
|
-
}
|
|
8
|
-
async get(key: string, defaultValue?: any): Promise<any> {
|
|
9
|
-
let val = _.get(this.store, key);
|
|
10
|
-
if (!val) {
|
|
11
|
-
this.set(key, defaultValue);
|
|
12
|
-
return defaultValue;
|
|
13
|
-
}
|
|
14
|
-
return val;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async set(key: string, value: any): Promise<any> {
|
|
18
|
-
return this.store = _.set(this.store, key, value);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async delete(key: string): Promise<boolean> {
|
|
22
|
-
return _.unset(this.store, key);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async has(key: string): Promise<boolean> {
|
|
26
|
-
return _.has(this.store, key);
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/utils/UtilTypes.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface IDBIToJSONArgs<T> {
|
|
2
|
-
reference?: {
|
|
3
|
-
ttl?: number;
|
|
4
|
-
data: (string | number | object | boolean | null | undefined)[];
|
|
5
|
-
};
|
|
6
|
-
overrides?: RecursivePartial<T>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type RecursivePartial<T> = {
|
|
10
|
-
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
11
|
-
}
|
package/src/utils/customId.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { DBI } from "../DBI";
|
|
2
|
-
import * as stuffs from "stuffs";
|
|
3
|
-
import { NamespaceEnums } from "../../generated/namespaceData";
|
|
4
|
-
|
|
5
|
-
export function buildCustomId(dbi: DBI<NamespaceEnums>, name: string, data: any[], ttl?: number, v2 = false): string {
|
|
6
|
-
let customId = [
|
|
7
|
-
`${v2 ? 'v2:' : ''}${name}`,
|
|
8
|
-
...data.map(value => {
|
|
9
|
-
if (typeof value == "string") return value;
|
|
10
|
-
if (typeof value == "number") return `π${value}`;
|
|
11
|
-
if (typeof value == "bigint") return `ᙖ${value.toString()}`;
|
|
12
|
-
if (typeof value == "boolean") return `𝞫${value ? 1 : 0}`;
|
|
13
|
-
if (typeof value == "undefined") return "🗶u";
|
|
14
|
-
if (value === null) return "🗶n";
|
|
15
|
-
if (value?.$ref) return `¤${value.$ref}`;
|
|
16
|
-
let id = stuffs.randomString(8);
|
|
17
|
-
Object.assign(value, {
|
|
18
|
-
$ref: id,
|
|
19
|
-
$unRef() { return dbi.data.refs.delete(id); },
|
|
20
|
-
});
|
|
21
|
-
dbi.data.refs.set(id, { at: Date.now(), value, ttl });
|
|
22
|
-
return `¤${id}`;
|
|
23
|
-
})
|
|
24
|
-
].join("—");
|
|
25
|
-
if (!dbi.config.strict) customId = customId.slice(0, 100);
|
|
26
|
-
if (customId.length > 100) throw new Error("Custom id cannot be longer than 100 characters.")
|
|
27
|
-
return customId;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function parseCustomId(dbi: DBI<NamespaceEnums>, customId: string): { name: string, data: any[], v2: boolean } {
|
|
31
|
-
let splitted = customId.split("—");
|
|
32
|
-
let name = splitted.shift();
|
|
33
|
-
let v2 = name.startsWith("v2:");
|
|
34
|
-
if (v2) name = name.slice(3);
|
|
35
|
-
let data = splitted.map(value => {
|
|
36
|
-
if (value.startsWith("π")) return Number(value.slice(1));
|
|
37
|
-
if (value.startsWith("𝞫")) return !!Number(value.slice(1));
|
|
38
|
-
if (value.startsWith("ᙖ")) return BigInt(value.slice(1));
|
|
39
|
-
if (value.startsWith("¤")) return dbi.data.refs.get(value.slice(1))?.value;
|
|
40
|
-
if (value == "🗶u") return undefined;
|
|
41
|
-
if (value == "🗶n") return null;
|
|
42
|
-
return value;
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
v2,
|
|
46
|
-
name,
|
|
47
|
-
data
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/utils/permissions.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* await recursiveImport("./src", [".js"], [".d.ts"])
|
|
7
|
-
*/
|
|
8
|
-
export async function recursiveImport(folderPath: string, exts: string[] = [".js"], ignore: string[] = [".d.ts", ".js.map", ".d.ts.map"]): Promise<any> {
|
|
9
|
-
let files = await fs.promises.readdir(folderPath, { withFileTypes: true });
|
|
10
|
-
let dirName = __dirname;
|
|
11
|
-
|
|
12
|
-
for (const file of files) {
|
|
13
|
-
let filePath = path.resolve(folderPath, file.name);
|
|
14
|
-
let relative = path.relative(dirName, filePath);
|
|
15
|
-
if (!relative.includes(`${path.sep}-`)) {
|
|
16
|
-
if (file.isDirectory()) {
|
|
17
|
-
await recursiveImport(filePath, exts, ignore);
|
|
18
|
-
} else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {
|
|
19
|
-
// Use require for CommonJS compatibility
|
|
20
|
-
// Wrap in try-catch for Bun compatibility - Bun throws "Missing 'default' export"
|
|
21
|
-
// but still executes the module's side effects (dbi.register calls)
|
|
22
|
-
try {
|
|
23
|
-
require(filePath);
|
|
24
|
-
} catch (e: any) {
|
|
25
|
-
// Ignore "Missing 'default' export" errors in Bun runtime
|
|
26
|
-
// The module's side effects still execute before the error is thrown
|
|
27
|
-
if (!e.message?.includes("Missing 'default' export") &&
|
|
28
|
-
!e.message?.includes("does not provide an export named 'default'")) {
|
|
29
|
-
throw e;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { unloadModule } from "./unloadModule";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* await recursiveUnload("./src", [".js"], [".d.ts"])
|
|
8
|
-
* await dbi.unload()
|
|
9
|
-
*/
|
|
10
|
-
export async function recursiveUnload(folderPath: string, exts: string[] = [".js"], ignore: string[] = [".d.ts",".js.map",".d.ts.map"]): Promise<any> {
|
|
11
|
-
let files = await fs.promises.readdir(folderPath, { withFileTypes: true });
|
|
12
|
-
let dirName = __dirname;
|
|
13
|
-
|
|
14
|
-
for (const file of files) {
|
|
15
|
-
let filePath = path.resolve(folderPath, file.name);
|
|
16
|
-
let relative = path.relative(dirName, filePath);
|
|
17
|
-
if (!relative.includes(`${path.sep}-`)) {
|
|
18
|
-
if (file.isDirectory()) {
|
|
19
|
-
await recursiveUnload(filePath, exts)
|
|
20
|
-
} else if (exts.some(i => file.name.endsWith(i)) && !ignore.some(i => file.name.endsWith(i))) {
|
|
21
|
-
unloadModule(filePath)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
package/test/index.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { createDBI } from "../src";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const dbi = createDBI("svelte", {
|
|
5
|
-
discord: {
|
|
6
|
-
token: process.env.DISCORD_TOKEN || "",
|
|
7
|
-
options: {
|
|
8
|
-
intents: [
|
|
9
|
-
"GuildMessages",
|
|
10
|
-
"Guilds",
|
|
11
|
-
"MessageContent",
|
|
12
|
-
"GuildMessageReactions"
|
|
13
|
-
],
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
references: {
|
|
17
|
-
autoClear: {
|
|
18
|
-
ttl: 60000 * 60, // 60 minutes
|
|
19
|
-
check: 60000 // every 60 seconds
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
dbi.register(({ ChatInput, HTMLComponentsV2 }) => {
|
|
25
|
-
// Svelte product showcase with Components V2
|
|
26
|
-
HTMLComponentsV2({
|
|
27
|
-
name: "product-showcase",
|
|
28
|
-
mode: 'svelte',
|
|
29
|
-
file: path.join(__dirname, "product-showcase.svelte")
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Test command
|
|
33
|
-
ChatInput({
|
|
34
|
-
name: "test-svelte",
|
|
35
|
-
description: "Test Svelte product showcase",
|
|
36
|
-
async onExecute({ interaction, dbi }) {
|
|
37
|
-
const showcase = dbi.interaction("product-showcase") as any;
|
|
38
|
-
|
|
39
|
-
const products = [
|
|
40
|
-
{
|
|
41
|
-
name: "Gaming Keyboard",
|
|
42
|
-
description: "RGB mechanical keyboard with Cherry MX switches",
|
|
43
|
-
price: 149,
|
|
44
|
-
image: "https://cdn.discordapp.com/embed/avatars/0.png",
|
|
45
|
-
category: "Electronics",
|
|
46
|
-
rating: 4.8,
|
|
47
|
-
stock: 25
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "Wireless Mouse",
|
|
51
|
-
description: "Ergonomic wireless mouse with 16000 DPI sensor",
|
|
52
|
-
price: 79,
|
|
53
|
-
image: "https://cdn.discordapp.com/embed/avatars/1.png",
|
|
54
|
-
category: "Electronics",
|
|
55
|
-
rating: 4.5,
|
|
56
|
-
stock: 42
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "USB-C Hub",
|
|
60
|
-
description: "7-in-1 USB-C hub with HDMI, USB 3.0, and SD card reader",
|
|
61
|
-
price: 59,
|
|
62
|
-
image: "https://cdn.discordapp.com/embed/avatars/2.png",
|
|
63
|
-
category: "Accessories",
|
|
64
|
-
rating: 4.3,
|
|
65
|
-
stock: 18
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "Monitor Stand",
|
|
69
|
-
description: "Adjustable monitor stand with cable management",
|
|
70
|
-
price: 89,
|
|
71
|
-
image: "https://cdn.discordapp.com/embed/avatars/3.png",
|
|
72
|
-
category: "Furniture",
|
|
73
|
-
rating: 4.6,
|
|
74
|
-
stock: 31
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "Webcam 4K",
|
|
78
|
-
description: "Ultra HD webcam with autofocus and noise-canceling mic",
|
|
79
|
-
price: 129,
|
|
80
|
-
image: "https://cdn.discordapp.com/embed/avatars/4.png",
|
|
81
|
-
category: "Electronics",
|
|
82
|
-
rating: 4.7,
|
|
83
|
-
stock: 15
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "Desk Lamp",
|
|
87
|
-
description: "LED desk lamp with adjustable brightness and color temperature",
|
|
88
|
-
price: 45,
|
|
89
|
-
image: "https://cdn.discordapp.com/embed/avatars/0.png",
|
|
90
|
-
category: "Furniture",
|
|
91
|
-
rating: 4.4,
|
|
92
|
-
stock: 60
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "Headphone Stand",
|
|
96
|
-
description: "Aluminum headphone stand with cable holder",
|
|
97
|
-
price: 35,
|
|
98
|
-
image: "https://cdn.discordapp.com/embed/avatars/1.png",
|
|
99
|
-
category: "Accessories",
|
|
100
|
-
rating: 4.2,
|
|
101
|
-
stock: 28
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "Gaming Headset",
|
|
105
|
-
description: "7.1 surround sound gaming headset with RGB lighting",
|
|
106
|
-
price: 99,
|
|
107
|
-
image: "https://cdn.discordapp.com/embed/avatars/2.png",
|
|
108
|
-
category: "Electronics",
|
|
109
|
-
rating: 4.6,
|
|
110
|
-
stock: 35
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: "Mouse Pad XL",
|
|
114
|
-
description: "Extended mouse pad with stitched edges, 900x400mm",
|
|
115
|
-
price: 25,
|
|
116
|
-
image: "https://cdn.discordapp.com/embed/avatars/3.png",
|
|
117
|
-
category: "Accessories",
|
|
118
|
-
rating: 4.8,
|
|
119
|
-
stock: 100
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: "Ergonomic Chair",
|
|
123
|
-
description: "Mesh office chair with lumbar support and adjustable armrests",
|
|
124
|
-
price: 299,
|
|
125
|
-
image: "https://cdn.discordapp.com/embed/avatars/4.png",
|
|
126
|
-
category: "Furniture",
|
|
127
|
-
rating: 4.9,
|
|
128
|
-
stock: 8
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: "Cable Management Kit",
|
|
132
|
-
description: "Complete kit with cable clips, ties, and sleeve",
|
|
133
|
-
price: 19,
|
|
134
|
-
image: "https://cdn.discordapp.com/embed/avatars/0.png",
|
|
135
|
-
category: "Accessories",
|
|
136
|
-
rating: 4.1,
|
|
137
|
-
stock: 75
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: "Portable SSD 1TB",
|
|
141
|
-
description: "Ultra-fast portable SSD with USB 3.2 Gen 2",
|
|
142
|
-
price: 109,
|
|
143
|
-
image: "https://cdn.discordapp.com/embed/avatars/1.png",
|
|
144
|
-
category: "Electronics",
|
|
145
|
-
rating: 4.7,
|
|
146
|
-
stock: 22
|
|
147
|
-
}
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
// Use send() method - this sends the message AND initializes lifecycle hooks (onMount)
|
|
151
|
-
// The interval in onMount will start immediately after the message is sent
|
|
152
|
-
await showcase.send(interaction, {
|
|
153
|
-
data: {
|
|
154
|
-
products,
|
|
155
|
-
currentIndex: 0,
|
|
156
|
-
cart: [],
|
|
157
|
-
view: 'browse',
|
|
158
|
-
elapsedTime: 0,
|
|
159
|
-
reviews: [],
|
|
160
|
-
editingProduct: null
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
setTimeout(() => {
|
|
168
|
-
console.log("Loading DBI...");
|
|
169
|
-
dbi.load().then(() => {
|
|
170
|
-
dbi.publish("Guild", "1341841733511806978")
|
|
171
|
-
console.log("DBI loaded.");
|
|
172
|
-
dbi.login().then(() => {
|
|
173
|
-
console.log("Bot is running with Svelte components!");
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}, 100);
|