trivious 1.4.0 → 1.4.1
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/core/client/trivious.client.cjs +1 -1
- package/dist/core/client/trivious.client.cjs.map +1 -1
- package/dist/core/client/trivious.client.d.cts +1 -1
- package/dist/core/client/trivious.client.d.ts +1 -1
- package/dist/core/client/trivious.client.js +1 -1
- package/dist/core/client/trivious.client.js.map +1 -1
- package/dist/core/commands/command.base.d.cts +1 -1
- package/dist/core/commands/command.base.d.ts +1 -1
- package/dist/core/commands/subcommand.base.d.cts +1 -1
- package/dist/core/commands/subcommand.base.d.ts +1 -1
- package/dist/core/components/component.base.d.cts +1 -1
- package/dist/core/components/component.base.d.ts +1 -1
- package/dist/core/events/clientReady.d.cts +1 -1
- package/dist/core/events/clientReady.d.ts +1 -1
- package/dist/core/events/interactionCreate.d.cts +1 -1
- package/dist/core/events/interactionCreate.d.ts +1 -1
- package/dist/core/registry/command.registry.d.cts +1 -1
- package/dist/core/registry/command.registry.d.ts +1 -1
- package/dist/core/registry/component.registry.d.cts +1 -1
- package/dist/core/registry/component.registry.d.ts +1 -1
- package/dist/core/registry/event.registry.d.cts +1 -1
- package/dist/core/registry/event.registry.d.ts +1 -1
- package/dist/core/registry/index.d.cts +1 -1
- package/dist/core/registry/index.d.ts +1 -1
- package/dist/core/registry/module.registry.d.cts +1 -1
- package/dist/core/registry/module.registry.d.ts +1 -1
- package/dist/{index-D5NcshUu.d.ts → index-BdQvQiVi.d.ts} +1 -1
- package/dist/{index-SutqlRMo.d.cts → index-DIZ3Scja.d.cts} +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared/typings/client.d.cts +1 -1
- package/dist/shared/typings/client.d.ts +1 -1
- package/dist/shared/typings/commands.d.cts +1 -1
- package/dist/shared/typings/commands.d.ts +1 -1
- package/dist/shared/typings/components.d.cts +1 -1
- package/dist/shared/typings/components.d.ts +1 -1
- package/dist/shared/typings/events.d.cts +1 -1
- package/dist/shared/typings/events.d.ts +1 -1
- package/dist/shared/typings/index.d.cts +1 -1
- package/dist/shared/typings/index.d.ts +1 -1
- package/dist/shared/typings/module.d.cts +1 -1
- package/dist/shared/typings/module.d.ts +1 -1
- package/dist/shared/typings/permissions.d.cts +1 -1
- package/dist/shared/typings/permissions.d.ts +1 -1
- package/dist/shared/utility/functions.d.cts +1 -1
- package/dist/shared/utility/functions.d.ts +1 -1
- package/package.json +1 -1
|
@@ -76,7 +76,7 @@ class TriviousClient extends discord_js.Client {
|
|
|
76
76
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
77
77
|
const commands = Array.from(this.registries.commands.get().values());
|
|
78
78
|
const body = [...commands.map((command) => command.toJSON())];
|
|
79
|
-
if (commandHashConfig.enabled) {
|
|
79
|
+
if (commandHashConfig && commandHashConfig.enabled) {
|
|
80
80
|
const hashFile = path__default.default.join(commandHashConfig.filePath || "data", "commands.hash");
|
|
81
81
|
const newHash = await functions_js.hashCommands(body);
|
|
82
82
|
let oldHash = "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["Client","registries","path","hashCommands","exists","readFileSync","REST","Routes"],"mappings":";;;;;;;;;;;;AAeA,MAAO,uBAAqCA,iBAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAaC,mBAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,YAAY,OAAA,EAAgC;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,QAAA,GAAW;AAChB,IAAA,MAAM,EAAE,UAAA,EAAAA,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O,MAAM,IAAI,MAAM,gDAAgD,CAAA;AAEzF,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,IAAA,CAAK,WAAW,QAAA,CAAS,GAAA,EAAI,CAAE,MAAA,EAAQ,CAAA;AACnE,IAAA,MAAM,IAAA,GAAO,CAAC,GAAG,QAAA,CAAS,IAAI,CAAA,OAAA,KAAW,OAAA,CAAQ,MAAA,EAAQ,CAAC,CAAA;AAE1D,IAAA,IAAI,kBAAkB,OAAA,EAAS;
|
|
1
|
+
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["Client","registries","path","hashCommands","exists","readFileSync","REST","Routes"],"mappings":";;;;;;;;;;;;AAeA,MAAO,uBAAqCA,iBAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAaC,mBAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,YAAY,OAAA,EAAgC;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,QAAA,GAAW;AAChB,IAAA,MAAM,EAAE,UAAA,EAAAA,WAAAA,EAAW,GAAI,IAAA;AACvB,IAAA,MAAMA,WAAAA,CAAW,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAA;AACtC,IAAA,OAAA,CAAQ,GAAA;AAAA,MACP,CAAA,kCAAA,EAAqCA,YAAW,QAAA,CAAS,GAAA,GAAM,IAAI,CAAA,WAAA,EAAcA,WAAAA,CAAW,MAAA,CAAO,GAAA,EAAI,CAAE,IAAI,CAAA,SAAA,EAAYA,WAAAA,CAAW,UAAA,CAAW,GAAA,EAAI,CAAE,IAAI,gBAAgBA,WAAAA,CAAW,OAAA,CAAQ,GAAA,EAAI,CA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kB,QAAA,IAAY,QAAQ,eAAe,CAAA;AAChF,MAAA,MAAM,OAAA,GAAU,MAAMC,yBAAA,CAAa,IAAI,CAAA;AACvC,MAAA,IAAI,OAAA,GAAU,EAAA;AAEd,MAAA,IAAI,MAAMC,mBAAA,CAAO,QAAQ,GAAG,OAAA,GAAUC,oBAAA,CAAa,UAAU,OAAO,CAAA;AACpE,MAAA,IAAI,YAAY,OAAA,EAAS;AACxB,QAAA,OAAA,CAAQ,MAAM,CAAA,4DAAA,CAA8D,CAAA;AAC5E,QAAA;AAAA,MACD;AAAA,IACD;AAEA,IAAA,MAAM,IAAA,GAAO,IAAIC,eAAA,CAAK,EAAE,SAAS,IAAA,EAAM,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA;AACvD,IAAA,MAAM,IAAA,CAAK,IAAIC,iBAAA,CAAO,mBAAA,CAAoB,QAAQ,CAAA,EAAG,EAAE,MAAM,CAAA;AAC7D,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.cjs","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport { TriviousClientOptions, PermissionLevel } from \"src/shared/typings/index.js\";\nimport { exists, hashCommands } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { readFileSync } from \"node:fs\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\tpublic readonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\tpublic readonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [...commands.map(command => command.toJSON())];\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = await hashCommands(body);\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`)\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
|
|
@@ -70,7 +70,7 @@ class TriviousClient extends Client {
|
|
|
70
70
|
if (!clientId || !token) throw new Error("[Trivious] Invalid clientId or token reference");
|
|
71
71
|
const commands = Array.from(this.registries.commands.get().values());
|
|
72
72
|
const body = [...commands.map((command) => command.toJSON())];
|
|
73
|
-
if (commandHashConfig.enabled) {
|
|
73
|
+
if (commandHashConfig && commandHashConfig.enabled) {
|
|
74
74
|
const hashFile = path.join(commandHashConfig.filePath || "data", "commands.hash");
|
|
75
75
|
const newHash = await hashCommands(body);
|
|
76
76
|
let oldHash = "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/client/trivious.client.ts"],"names":["registries"],"mappings":";;;;;;AAeA,MAAO,uBAAqC,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQlC,aAAa,UAAA,EAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,YAAY,OAAA,EAAgC;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA;AAAA,EACjB;AAAA;AAA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MAAM,WAAW,IAAA,CAAK,IAAA,CAAK,iBAAA,CAAkB,QAAA,IAAY,QAAQ,eAAe,CAAA;AAChF,MAAA,MAAM,OAAA,GAAU,MAAM,YAAA,CAAa,IAAI,CAAA;AACvC,MAAA,IAAI,OAAA,GAAU,EAAA;AAEd,MAAA,IAAI,MAAM,MAAA,CAAO,QAAQ,GAAG,OAAA,GAAU,YAAA,CAAa,UAAU,OAAO,CAAA;AACpE,MAAA,IAAI,YAAY,OAAA,EAAS;AACxB,QAAA,OAAA,CAAQ,MAAM,CAAA,4DAAA,CAA8D,CAAA;AAC5E,QAAA;AAAA,MACD;AAAA,IACD;AAEA,IAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,EAAE,SAAS,IAAA,EAAM,CAAA,CAAE,QAAA,CAAS,KAAK,CAAA;AACvD,IAAA,MAAM,IAAA,CAAK,IAAI,MAAA,CAAO,mBAAA,CAAoB,QAAQ,CAAA,EAAG,EAAE,MAAM,CAAA;AAC7D,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,SAAA,CAAW,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,KAAA,EAAwC;AAC1D,IAAA,IAAA,CAAK,SAAS,eAAA,GAAkB,KAAA;AAAA,EACjC;AAAA,EAEA,IAAI,eAAA,GAAkB;AACrB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,eAAA,IAAmB,EAAC;AAAA,EAC1C;AACD","file":"trivious.client.js","sourcesContent":["import { Client, REST, Routes } from \"discord.js\";\nimport { registries } from \"../registry/index.js\";\nimport { TriviousClientOptions, PermissionLevel } from \"src/shared/typings/index.js\";\nimport { exists, hashCommands } from \"src/shared/utility/functions.js\";\nimport path from \"node:path\";\nimport { readFileSync } from \"node:fs\";\n\n/**\n * Trivious base client.\n *\n * @export\n * @class TriviousClient\n * @typedef {TriviousClient}\n * @extends {Client}\n */\nexport default class TriviousClient extends Client {\n\t/**\n\t * Client registries.\n\t *\n\t * @public\n\t * @readonly\n\t * @type {*}\n\t */\n\tpublic readonly registries = registries();\n\t/**\n\t * Client copy of the constructor options.\n\t *\n\t * @private\n\t * @type {TriviousClientOptions}\n\t */\n\tpublic readonly _options: TriviousClientOptions;\n\n\t/**\n\t * Creates an instance of TriviousClient.\n\t *\n\t * @constructor\n\t * @param {TriviousClientOptions} options\n\t */\n\tconstructor(options: TriviousClientOptions) {\n\t\tsuper(options);\n\t\tthis._options = options;\n\t}\n\n\t/**\n\t * Load all registries.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync register() {\n\t\tconst { registries } = this;\n\t\tawait registries.loadAll(this._options);\n\t\tconsole.log(\n\t\t\t`[Trivious] Loaded all registries (${registries.commands.get().size} commands, ${registries.events.get().size} events, ${registries.components.get().size} components, ${registries.modules.get().size} modules)`\n\t\t);\n\t}\n\n\t/**\n\t * Login and start the bot.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync start() {\n\t\tif (!process.env[this._options.tokenReference]) {\n\t\t\tif (process.env.NODE_ENV !== \"production\") return;\n\t\t\telse throw new Error(\"[Trivious] Invalid token reference\");\n\t\t}\n\n\t\tthis.registries.bind(this);\n\t\tawait this.login(process.env[this._options.tokenReference]);\n\t}\n\n\t/**\n\t * Deploy all commands.\n\t *\n\t * @async\n\t * @returns {*}\n\t */\n\tasync deploy() {\n\t\tconst { commandHashConfig } = this._options;\n\t\tconst clientId = process.env[this._options.clientIdReference];\n\t\tconst token = process.env[this._options.tokenReference];\n\t\tif (!clientId || !token) throw new Error(\"[Trivious] Invalid clientId or token reference\");\n\n\t\tconst commands = Array.from(this.registries.commands.get().values());\n\t\tconst body = [...commands.map(command => command.toJSON())];\n\n\t\tif (commandHashConfig && commandHashConfig.enabled) {\n\t\t\tconst hashFile = path.join(commandHashConfig.filePath || \"data\", \"commands.hash\");\n\t\t\tconst newHash = await hashCommands(body);\n\t\t\tlet oldHash = \"\";\n\n\t\t\tif (await exists(hashFile)) oldHash = readFileSync(hashFile, \"utf-8\");\n\t\t\tif (newHash === oldHash) {\n\t\t\t\tconsole.debug(`[Trivious] No changes in commands found, skipping deployment`)\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst rest = new REST({ version: \"10\" }).setToken(token);\n\t\tawait rest.put(Routes.applicationCommands(clientId), { body });\n\t\tconsole.log(`[Trivious] Deployed ${body.length} commands`);\n\t}\n\n\t/**\n\t * Set the roles tied to a permission level.\n\t *\n\t * @param {Record<string, PermissionLevel>} roles\n\t */\n\tsetRolePermissions(roles: Record<string, PermissionLevel>) {\n\t\tthis._options.rolePermissions = roles;\n\t}\n\n\tget rolePermissions() {\n\t\treturn this._options.rolePermissions ?? {};\n\t}\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-
|
|
2
|
+
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-DIZ3Scja.cjs';
|
|
3
3
|
import '../../shared/typings/registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-
|
|
2
|
+
export { j as CommandBuilder, l as ContextMenuBuilder, k as ContextMenuCommand, S as SlashCommand, i as default } from '../../index-BdQvQiVi.js';
|
|
3
3
|
import '../../shared/typings/registry.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-
|
|
1
|
+
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-DIZ3Scja.cjs';
|
|
2
2
|
import '../../shared/typings/registry.cjs';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-
|
|
1
|
+
import { C as CommandRegistry, a as ComponentRegistry, E as EventRegistry, M as ModuleRegistry, b as TriviousClientOptions, T as TriviousClient } from '../../index-BdQvQiVi.js';
|
|
2
2
|
import '../../shared/typings/registry.js';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-
|
|
2
|
+
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-DIZ3Scja.cjs';
|
|
3
3
|
export { BaseRegistry } from './shared/typings/registry.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-
|
|
2
|
+
export { A as AnyCommand, B as ButtonInteraction, w as ChatInputCommandInteraction, i as Command, j as CommandBuilder, o as CommandInteraction, p as CommandMetadata, C as CommandRegistry, u as Component, v as ComponentBuilder, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, a as ComponentRegistry, e as ComponentType, l as ContextMenuBuilder, k as ContextMenuCommand, z as ContextMenuCommandInteraction, r as ContextMenuMetadata, s as Event, y as ModalSubmitInteraction, t as Module, P as PermissionLevel, S as SlashCommand, x as StringSelectMenuInteraction, m as Subcommand, n as SubcommandBuilder, q as SubcommandMetadata, T as TriviousClient, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from './index-BdQvQiVi.js';
|
|
3
3
|
export { BaseRegistry } from './shared/typings/registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-DIZ3Scja.cjs';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import './registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, r as ContextMenuMetadata, q as SubcommandMetadata } from '../../index-BdQvQiVi.js';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import './registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-
|
|
2
|
+
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-DIZ3Scja.cjs';
|
|
3
3
|
import './registry.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-
|
|
2
|
+
export { c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, h as deconstructCustomId } from '../../index-BdQvQiVi.js';
|
|
3
3
|
import './registry.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-DIZ3Scja.cjs';
|
|
2
2
|
export { BaseRegistry } from './registry.cjs';
|
|
3
3
|
import 'discord.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-
|
|
1
|
+
export { A as AnyCommand, o as CommandInteraction, p as CommandMetadata, c as ComponentCustomIdTag, d as ComponentInteraction, f as ComponentMetadata, e as ComponentType, r as ContextMenuMetadata, s as Event, t as Module, P as PermissionLevel, q as SubcommandMetadata, b as TriviousClientOptions, h as deconstructCustomId, g as getPermissionLevel } from '../../index-BdQvQiVi.js';
|
|
2
2
|
export { BaseRegistry } from './registry.js';
|
|
3
3
|
import 'discord.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-DIZ3Scja.cjs';
|
|
2
2
|
import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
|
|
3
3
|
import '../typings/registry.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TriviousClient, P as PermissionLevel } from '../../index-
|
|
1
|
+
import { T as TriviousClient, P as PermissionLevel } from '../../index-BdQvQiVi.js';
|
|
2
2
|
import { User, GuildMember, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
|
|
3
3
|
import '../typings/registry.js';
|
|
4
4
|
|