trivious 2.0.5 → 2.0.6
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/features/customId/methods.customid.d.ts +11 -14
- package/dist/features/customId/methods.customid.js +27 -18
- package/dist/features/customId/methods.customid.js.map +1 -1
- package/dist/features/events/presets/interactionCreate.js +3 -3
- package/dist/features/events/presets/interactionCreate.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/package.json +1 -1
|
@@ -3,18 +3,15 @@ import '../client/client.types.js';
|
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
import '../../modules.types-Czzl6XR9.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @throws {TriviousError} If encoded length exceeds 100 characters
|
|
17
|
-
*/
|
|
18
|
-
declare const encodeCustomId: (options: ComponentCustomId) => string;
|
|
6
|
+
declare const customId: {
|
|
7
|
+
/**
|
|
8
|
+
* Decode a customId into its parts
|
|
9
|
+
*/
|
|
10
|
+
readonly decode: (customId: string) => ComponentCustomId;
|
|
11
|
+
/**
|
|
12
|
+
* Encode a customId
|
|
13
|
+
*/
|
|
14
|
+
readonly encode: (options: ComponentCustomId) => string;
|
|
15
|
+
};
|
|
19
16
|
|
|
20
|
-
export {
|
|
17
|
+
export { customId as default };
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { TriviousError } from '../../utility/errors.js';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
identifier,
|
|
9
|
-
data,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
const customId = {
|
|
4
|
+
/**
|
|
5
|
+
* Decode a customId into its parts
|
|
6
|
+
*/
|
|
7
|
+
decode: (customId2) => {
|
|
8
|
+
const [context, identifier, info] = customId2.split(":");
|
|
9
|
+
const [data, ...tags] = info?.split(".");
|
|
10
|
+
return {
|
|
11
|
+
context,
|
|
12
|
+
identifier,
|
|
13
|
+
data,
|
|
14
|
+
tags
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* Encode a customId
|
|
19
|
+
*/
|
|
20
|
+
encode: (options) => {
|
|
21
|
+
const { context, identifier, data, tags } = options;
|
|
22
|
+
let customId2 = `${context}:${identifier}`;
|
|
23
|
+
if (data) customId2 += `:${data}`;
|
|
24
|
+
if (tags) customId2 += `.${tags.join(".")}`;
|
|
25
|
+
if (customId2.length > 100) throw new TriviousError("Encoded customId exceeds 100 characters.");
|
|
26
|
+
return customId2;
|
|
27
|
+
}
|
|
20
28
|
};
|
|
29
|
+
var methods_customid_default = customId;
|
|
21
30
|
|
|
22
|
-
export {
|
|
31
|
+
export { methods_customid_default as default };
|
|
23
32
|
//# sourceMappingURL=methods.customid.js.map
|
|
24
33
|
//# sourceMappingURL=methods.customid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/customId/methods.customid.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"sources":["../../../src/features/customId/methods.customid.ts"],"names":["customId"],"mappings":";;AAGA,MAAM,QAAA,GAAW;AAAA;AAAA;AAAA;AAAA,EAIhB,MAAA,EAAQ,CAACA,SAAAA,KAAqB;AAC7B,IAAA,MAAM,CAAC,OAAA,EAAS,UAAA,EAAY,IAAI,CAAA,GAAIA,SAAAA,CAAS,MAAM,GAAG,CAAA;AAKtD,IAAA,MAAM,CAAC,IAAA,EAAM,GAAG,IAAI,CAAA,GAAI,IAAA,EAAM,MAAM,GAAG,CAAA;AAEvC,IAAA,OAAO;AAAA,MACN,OAAA;AAAA,MACA,UAAA;AAAA,MACA,IAAA;AAAA,MACA;AAAA,KACD;AAAA,EACD,CAAA;AAAA;AAAA;AAAA;AAAA,EAIA,MAAA,EAAQ,CAAC,OAAA,KAA+B;AACvC,IAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAY,IAAA,EAAM,MAAK,GAAI,OAAA;AAC5C,IAAA,IAAIA,SAAAA,GAAW,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,UAAU,CAAA,CAAA;AAEvC,IAAA,IAAI,IAAA,EAAMA,SAAAA,IAAY,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAC9B,IAAA,IAAI,MAAMA,SAAAA,IAAY,IAAI,IAAA,CAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAExC,IAAA,IAAIA,UAAS,MAAA,GAAS,GAAA,EAAK,MAAM,IAAI,cAAc,0CAA0C,CAAA;AAC7F,IAAA,OAAOA,SAAAA;AAAA,EACR;AACD,CAAA;AAEA,IAAO,wBAAA,GAAQ","file":"methods.customid.js","sourcesContent":["import { ComponentContext, ComponentCustomId, ComponentTag } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\n\nconst customId = {\n\t/**\n\t * Decode a customId into its parts\n\t */\n\tdecode: (customId: string) => {\n\t\tconst [context, identifier, info] = customId.split(\":\") as [\n\t\t\tComponentContext,\n\t\t\tstring,\n\t\t\tstring | undefined,\n\t\t];\n\t\tconst [data, ...tags] = info?.split(\".\") as [string | undefined, ...ComponentTag[]];\n\n\t\treturn {\n\t\t\tcontext,\n\t\t\tidentifier,\n\t\t\tdata,\n\t\t\ttags,\n\t\t} as ComponentCustomId;\n\t},\n\t/**\n\t * Encode a customId\n\t */\n\tencode: (options: ComponentCustomId) => {\n\t\tconst { context, identifier, data, tags } = options;\n\t\tlet customId = `${context}:${identifier}`;\n\n\t\tif (data) customId += `:${data}`;\n\t\tif (tags) customId += `.${tags.join(\".\")}`;\n\n\t\tif (customId.length > 100) throw new TriviousError(\"Encoded customId exceeds 100 characters.\");\n\t\treturn customId;\n\t},\n} as const;\n\nexport default customId;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ComponentContext } from '../../../shared/typings.js';
|
|
1
2
|
import { ApplicationCommandType, ButtonInteraction, ModalSubmitInteraction } from 'discord.js';
|
|
2
3
|
import { interactionReply, handleSlashCommand } from '../../../features/commands/methods.commands.js';
|
|
3
|
-
import
|
|
4
|
-
import { ComponentContext } from '../../../shared/typings.js';
|
|
4
|
+
import customId from '../../../features/customId/methods.customid.js';
|
|
5
5
|
|
|
6
6
|
var interactionCreate_default = {
|
|
7
7
|
name: "interactionCreate",
|
|
@@ -24,7 +24,7 @@ var interactionCreate_default = {
|
|
|
24
24
|
await command.execute(client, interaction);
|
|
25
25
|
}
|
|
26
26
|
} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
|
|
27
|
-
const { context, identifier, tags } =
|
|
27
|
+
const { context, identifier, tags } = customId.decode(interaction.customId);
|
|
28
28
|
if (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))
|
|
29
29
|
return;
|
|
30
30
|
if (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"names":[],"mappings":";;;;;AAKA,IAAO,yBAAA,GAAQ;AAAA,EACd,IAAA,EAAM,mBAAA;AAAA,EACN,MAAM,OAAA,CAAQ,MAAA,EAAQ,WAAA,EAAa;AAClC,IAAA,IAAI,WAAA,CAAY,kBAAA,EAAmB,IAAK,WAAA,CAAY,sBAAqB,EAAG;AAC3E,MAAA,MAAM,EAAE,aAAY,GAAI,WAAA;AAExB,MAAA,MAAM,YAAA,GAAe,WAAA,CAAY,kBAAA,EAAmB,GACjD,MAAA,CAAO,OAAO,QAAA,CAAS,SAAA,GACvB,MAAA,CAAO,MAAA,CAAO,QAAA,CAAS,OAAA;AAC1B,MAAA,MAAM,OAAA,GAAU,YAAA,CAAa,GAAA,CA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interactionCreate.js","sourcesContent":["import { ComponentContext, type ContextCommandData, type Event } from \"#typings\";\nimport { ApplicationCommandType, ButtonInteraction, ModalSubmitInteraction } from \"discord.js\";\nimport { handleSlashCommand, interactionReply } from \"src/features/commands/methods.commands.js\";\nimport customId from \"src/features/customId/methods.customid.js\";\n\nexport default {\n\tname: \"interactionCreate\",\n\tasync execute(client, interaction) {\n\t\tif (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {\n\t\t\tconst { commandName } = interaction;\n\n\t\t\tconst storeToCheck = interaction.isChatInputCommand()\n\t\t\t\t? client.stores.commands.chatInput\n\t\t\t\t: client.stores.commands.context;\n\t\t\tconst command = storeToCheck.get(commandName);\n\n\t\t\tif (!command) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tcommand.commandType === ApplicationCommandType.ChatInput &&\n\t\t\t\tinteraction.isChatInputCommand()\n\t\t\t) {\n\t\t\t\tawait handleSlashCommand(client, command, interaction);\n\t\t\t} else {\n\t\t\t\tawait (command as ContextCommandData).execute(client, interaction as never);\n\t\t\t}\n\t\t} else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {\n\t\t\tconst { context, identifier, tags } = customId.decode(interaction.customId);\n\n\t\t\tif (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))\n\t\t\t\treturn;\n\t\t\tif (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))\n\t\t\t\treturn;\n\t\t\tif (tags && tags.includes(\"awaited\")) return;\n\n\t\t\tconst component = client.stores.components.get(identifier);\n\n\t\t\tif (!component) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"Command is outdated, inactive, or does not have a handler!\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { createActionRow, createEmbed } from './features/builders/utility.builders.js';
|
|
2
2
|
export { handleSlashCommand, interactionReply } from './features/commands/methods.commands.js';
|
|
3
|
-
export { decodeCustomId, encodeCustomId } from './features/customId/methods.customid.js';
|
|
4
3
|
export { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure } from './features/client/client.types.js';
|
|
5
4
|
export { B as BaseChatInputCommandData, a as BaseCommandData, b as BaseContextCommandData, C as ChatInputCommandContext, c as CommandFlags, d as CommandFunction, e as Component, f as ComponentContext, g as ComponentFlags, h as ComponentInteraction, i as ContextCommandData, E as Event, M as MessageCommandData, j as Module, S as SlashCommandData, k as SlashSubcommandData, l as SlashSubcommandGroupData, T as TriviousClient, U as UserCommandData } from './modules.types-Czzl6XR9.js';
|
|
6
5
|
export { ComponentCustomId, ComponentTag } from './features/customId/customid.types.js';
|