trivious 2.1.13 → 2.2.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.
Files changed (43) hide show
  1. package/README.md +46 -8
  2. package/dist/features/client/deploy.client.d.ts +1 -1
  3. package/dist/features/client/trivious.client.d.ts +1 -1
  4. package/dist/features/commands/builders.commands.d.ts +1 -1
  5. package/dist/features/commands/commands.types.d.ts +1 -1
  6. package/dist/features/commands/methods.commands.d.ts +1 -1
  7. package/dist/features/commands/registry.commands.d.ts +1 -1
  8. package/dist/features/components/builders.components.d.ts +31 -0
  9. package/dist/features/components/builders.components.js +29 -0
  10. package/dist/features/components/builders.components.js.map +1 -0
  11. package/dist/features/components/components.types.d.ts +1 -1
  12. package/dist/features/components/components.types.js.map +1 -1
  13. package/dist/features/components/registry.components.d.ts +1 -1
  14. package/dist/features/components/registry.components.js +7 -1
  15. package/dist/features/components/registry.components.js.map +1 -1
  16. package/dist/features/customId/customid.types.d.ts +1 -1
  17. package/dist/features/customId/methods.customid.d.ts +1 -1
  18. package/dist/features/events/builders.events.d.ts +19 -0
  19. package/dist/features/events/builders.events.js +13 -0
  20. package/dist/features/events/builders.events.js.map +1 -0
  21. package/dist/features/events/events.types.d.ts +1 -1
  22. package/dist/features/events/presets/clientReady.d.ts +1 -1
  23. package/dist/features/events/presets/interactionCreate.d.ts +1 -1
  24. package/dist/features/events/presets/interactionCreate.js +2 -0
  25. package/dist/features/events/presets/interactionCreate.js.map +1 -1
  26. package/dist/features/events/registry.events.d.ts +1 -1
  27. package/dist/features/events/registry.events.js +2 -0
  28. package/dist/features/events/registry.events.js.map +1 -1
  29. package/dist/features/modules/builders.modules.d.ts +13 -0
  30. package/dist/features/modules/builders.modules.js +7 -0
  31. package/dist/features/modules/builders.modules.js.map +1 -0
  32. package/dist/features/modules/modules.types.d.ts +1 -1
  33. package/dist/features/modules/registry.modules.d.ts +1 -1
  34. package/dist/features/modules/registry.modules.js +6 -2
  35. package/dist/features/modules/registry.modules.js.map +1 -1
  36. package/dist/features/permissions/methods.permissions.d.ts +1 -1
  37. package/dist/index.d.ts +8 -5
  38. package/dist/index.js +5 -2
  39. package/dist/{modules.types-BY9Ncpz7.d.ts → modules.types-lYoNHt-m.d.ts} +10 -5
  40. package/dist/shared/registries.d.ts +1 -1
  41. package/dist/shared/typings.d.ts +1 -1
  42. package/dist/utility/errors.d.ts +1 -1
  43. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Trivious
2
2
 
3
- Discord.js framework
3
+ Spend less time wiring, and more time writing behaviour.
4
+
5
+ - declarative handlers
6
+ - structured files
7
+ - encoded interaction routing
8
+ - slash command auto-loading & deployment
9
+ - builtin permission handling
10
+
11
+ Looking for support? Join the Alien Logger server: https://discord.gg/ScY9s6xjFb
4
12
 
5
13
  ---
6
14
 
@@ -28,9 +36,17 @@ const client = new TriviousClient({
28
36
  tokenReference: "BOT_TOKEN",
29
37
  clientIdReference: "CLIENT_ID",
30
38
  },
31
- corePath: "core", // Folder containing your bot's processes
39
+ corePath: "core", // Folder containing your bot's handlers
32
40
  intents: [GatewayIntentBits.Guilds],
33
41
  ownerUserIds: ["1234"],
42
+
43
+ // Auto-deploy slash commands.
44
+ // Using the commandHash feature is recommended
45
+ // since it won't redeploy unchanged commands every restart.
46
+ commandHashConfig: {
47
+ enabled: true,
48
+ persistentDataPath: "data",
49
+ },
34
50
  });
35
51
 
36
52
  (async () => {
@@ -49,6 +65,14 @@ const client = new TriviousClient({
49
65
 
50
66
  ---
51
67
 
68
+ ### Additional packages
69
+
70
+ [Google Sheets API client](https://github.com/commonly-ts/trivious-sheets) - Integrate your bot with a Google Service Account to automate certain processes on Sheets
71
+
72
+ [Trello API client](https://github.com/commonly-ts/trivious-trello) - Integrate your bot with Trello to automate cards handling
73
+
74
+ ---
75
+
52
76
  ### Included Default Events
53
77
 
54
78
  Trivious automatically includes and inserts `clientReady` and `interactionCreate` handlers, which can be overwritten.
@@ -59,6 +83,7 @@ These default events can be found in `src/features/events/presets` in the Trivio
59
83
  ---
60
84
 
61
85
  ### Code examples
86
+
62
87
  Examples for commands, components, events and modules can be found at https://github.com/commonly-ts/discord-bot-template/tree/main/templates.
63
88
 
64
89
  ---
@@ -68,7 +93,7 @@ Examples for commands, components, events and modules can be found at https://gi
68
93
  ```ts
69
94
  // commands/debug/index.ts
70
95
  import { ApplicationCommandType, SlashCommandBuilder } from "discord.js";
71
- import { SlashCommandData } from "trivious";
96
+ import { createSlashCommand, SlashCommandData } from "trivious";
72
97
 
73
98
  export default {
74
99
  active: true,
@@ -77,6 +102,17 @@ export default {
77
102
  flags: ["Cached", "EphemeralReply", "DeferReply"],
78
103
  data: new SlashCommandBuilder().setName("debug").setDescription("Debug commands"),
79
104
  } satisfies SlashCommandData;
105
+
106
+ // Or alternatively...
107
+ export default createSlashCommand({
108
+ active: true,
109
+ flags: ["Cached", "EphemeralReply", "DeferReply"],
110
+ data: new SlashCommandBuilder().setName("debug").setDescription("Debug commands"),
111
+ });
112
+
113
+ // You have the choice to do export default {} satisfies <...> OR use
114
+ // a builder such as createSlashCommand (cleaner & less repetitive).
115
+ // There are builders available for commands, components, events and modules.
80
116
  ```
81
117
 
82
118
  ### Creating a Subcommand Group
@@ -130,17 +166,19 @@ export default {
130
166
 
131
167
  ### Project Structure
132
168
 
133
- Any project structure (e.g. type-based, feature-based) is acceptable as long as everything you expect to be registered are within the core directory.
169
+ Any project structure (e.g. type-based, feature-based) is acceptable as long as everything you expect to be registered is within the core directory.
134
170
 
135
171
  For example, if all of your commands, components, events and modules are anywhere inside src/features, assuming they export the correct data, they will be detected and registered to the client.
136
172
 
137
- The only required specific structure are for slash commands, as shown below.
173
+ The only required specific structure is for slash commands, as shown below.
138
174
 
139
175
  ```
140
176
  command/
141
- ├── index.ts
177
+ ├── index.ts*
142
178
  ├── subcommand.ts
143
179
  └── subcommand-group/
144
- ├── index.ts
145
- └──subcommand.ts
180
+ ├── index.ts*
181
+ └── subcommand.ts
182
+
183
+ *file name must be exact
146
184
  ```
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-BY9Ncpz7.js';
1
+ import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import './client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
2
  import './client.types.js';
3
- export { T as default } from '../../modules.types-BY9Ncpz7.js';
3
+ export { T as default } from '../../modules.types-lYoNHt-m.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,4 +1,4 @@
1
- import { h as ContextCommandData, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData } from '../../modules.types-BY9Ncpz7.js';
1
+ import { h as ContextCommandData, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData } from '../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
- export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, h as ContextCommandData, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData } from '../../modules.types-BY9Ncpz7.js';
2
+ export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, h as ContextCommandData, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';
@@ -1,5 +1,5 @@
1
1
  import { ChatInputCommandInteraction, Interaction, CacheType, InteractionReplyOptions, InteractionResponse, InteractionEditReplyOptions, Message, MessagePayload } from 'discord.js';
2
- import { T as TriviousClient, S as SlashCommandData, b as CommandFlags } from '../../modules.types-BY9Ncpz7.js';
2
+ import { T as TriviousClient, S as SlashCommandData, b as CommandFlags } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-BY9Ncpz7.js';
1
+ import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -0,0 +1,31 @@
1
+ import { d as Component, e as ComponentContext } from '../../modules.types-lYoNHt-m.js';
2
+ import 'discord.js';
3
+ import '../client/client.types.js';
4
+ import '../permissions/permissions.types.js';
5
+
6
+ /**
7
+ * Create component handler
8
+ * @param data Component data
9
+ * @returns Component
10
+ */
11
+ declare function createComponent<Context extends ComponentContext = ComponentContext>(data: Component<Context>): Component<Context>;
12
+ /**
13
+ * Create a button component handler
14
+ * @param data Component data
15
+ * @returns Button Component
16
+ */
17
+ declare function createButtonComponent(data: Omit<Component, "context" | "component">): Component<ComponentContext.Button>;
18
+ /**
19
+ * Create a select menu component handler
20
+ * @param data Component data
21
+ * @returns AnySelectMenu Component
22
+ */
23
+ declare function createSelectMenuComponent(data: Omit<Component, "context" | "component">): Component<ComponentContext.SelectMenu>;
24
+ /**
25
+ * Create a modal component handler
26
+ * @param data Component data
27
+ * @returns Modal Component
28
+ */
29
+ declare function createModalComponent(data: Omit<Component, "context" | "component">): Component<ComponentContext.Modal>;
30
+
31
+ export { createButtonComponent, createComponent, createModalComponent, createSelectMenuComponent };
@@ -0,0 +1,29 @@
1
+ import { ComponentContext } from '../../shared/typings.js';
2
+
3
+ function createComponent(data) {
4
+ return {
5
+ ...data
6
+ };
7
+ }
8
+ function createButtonComponent(data) {
9
+ return {
10
+ context: ComponentContext.Button,
11
+ ...data
12
+ };
13
+ }
14
+ function createSelectMenuComponent(data) {
15
+ return {
16
+ context: ComponentContext.SelectMenu,
17
+ ...data
18
+ };
19
+ }
20
+ function createModalComponent(data) {
21
+ return {
22
+ context: ComponentContext.Modal,
23
+ ...data
24
+ };
25
+ }
26
+
27
+ export { createButtonComponent, createComponent, createModalComponent, createSelectMenuComponent };
28
+ //# sourceMappingURL=builders.components.js.map
29
+ //# sourceMappingURL=builders.components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/features/components/builders.components.ts"],"names":[],"mappings":";;AAOO,SAAS,gBACf,IAAA,EACqB;AACrB,EAAA,OAAO;AAAA,IACN,GAAG;AAAA,GACJ;AACD;AAOO,SAAS,sBACf,IAAA,EACqC;AACrC,EAAA,OAAO;AAAA,IACN,SAAS,gBAAA,CAAiB,MAAA;AAAA,IAC1B,GAAG;AAAA,GACJ;AACD;AAOO,SAAS,0BACf,IAAA,EACyC;AACzC,EAAA,OAAO;AAAA,IACN,SAAS,gBAAA,CAAiB,UAAA;AAAA,IAC1B,GAAG;AAAA,GACJ;AACD;AAOO,SAAS,qBACf,IAAA,EACoC;AACpC,EAAA,OAAO;AAAA,IACN,SAAS,gBAAA,CAAiB,KAAA;AAAA,IAC1B,GAAG;AAAA,GACJ;AACD","file":"builders.components.js","sourcesContent":["import { Component, ComponentContext } from \"#typings\";\n\n/**\n * Create component handler\n * @param data Component data\n * @returns Component\n */\nexport function createComponent<Context extends ComponentContext = ComponentContext>(\n\tdata: Component<Context>\n): Component<Context> {\n\treturn {\n\t\t...data,\n\t} satisfies Component<Context>;\n}\n\n/**\n * Create a button component handler\n * @param data Component data\n * @returns Button Component\n */\nexport function createButtonComponent(\n\tdata: Omit<Component, \"context\" | \"component\">\n): Component<ComponentContext.Button> {\n\treturn {\n\t\tcontext: ComponentContext.Button,\n\t\t...data,\n\t} satisfies Component;\n}\n\n/**\n * Create a select menu component handler\n * @param data Component data\n * @returns AnySelectMenu Component\n */\nexport function createSelectMenuComponent(\n\tdata: Omit<Component, \"context\" | \"component\">\n): Component<ComponentContext.SelectMenu> {\n\treturn {\n\t\tcontext: ComponentContext.SelectMenu,\n\t\t...data,\n\t} satisfies Component;\n}\n\n/**\n * Create a modal component handler\n * @param data Component data\n * @returns Modal Component\n */\nexport function createModalComponent(\n\tdata: Omit<Component, \"context\" | \"component\">\n): Component<ComponentContext.Modal> {\n\treturn {\n\t\tcontext: ComponentContext.Modal,\n\t\t...data,\n\t} satisfies Component;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
- export { d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction } from '../../modules.types-BY9Ncpz7.js';
2
+ export { d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import '../client/client.types.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/components/components.types.ts"],"names":["ComponentContext"],"mappings":"AASO,IAAK,gBAAA,qBAAAA,iBAAAA,KAAL;AACN,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAA;AACA,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;AACA,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAA;AAHW,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"components.types.js","sourcesContent":["import { CommandPermissionValues, TriviousClient } from \"#typings\";\nimport { AnySelectMenuInteraction, ButtonInteraction, ModalSubmitInteraction } from \"discord.js\";\n\nexport type ComponentFlags = \"Cached\" | \"DeferReply\" | \"EphemeralReply\" | \"ExpectModal\";\nexport type ComponentInteraction =\n\t| AnySelectMenuInteraction\n\t| ButtonInteraction\n\t| ModalSubmitInteraction;\n\nexport enum ComponentContext {\n\tButton,\n\tSelectMenu,\n\tModal,\n}\n\n/**\n * Trivious component\n * @param component The component type\n * @param identifier The unique identifier inside the custom id\n * @param flags The component flags\n * @param execute Component handler\n */\nexport interface Component {\n\tcomponent: ComponentContext;\n\tidentifier: string;\n\tflags?: ComponentFlags[];\n\tpermissions?: CommandPermissionValues;\n\texecute: (client: TriviousClient, interaction: ComponentInteraction) => Promise<void>;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/components/components.types.ts"],"names":["ComponentContext"],"mappings":"AASO,IAAK,gBAAA,qBAAAA,iBAAAA,KAAL;AACN,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAA;AACA,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,YAAA,CAAA,GAAA,CAAA,CAAA,GAAA,YAAA;AACA,EAAAA,iBAAAA,CAAAA,iBAAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAA;AAHW,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"components.types.js","sourcesContent":["import { CommandPermissionValues, TriviousClient } from \"#typings\";\nimport { AnySelectMenuInteraction, ButtonInteraction, ModalSubmitInteraction } from \"discord.js\";\n\nexport type ComponentFlags = \"Cached\" | \"DeferReply\" | \"EphemeralReply\" | \"ExpectModal\";\nexport type ComponentInteraction =\n\t| AnySelectMenuInteraction\n\t| ButtonInteraction\n\t| ModalSubmitInteraction;\n\nexport enum ComponentContext {\n\tButton,\n\tSelectMenu,\n\tModal,\n}\n\ntype ContextualComponentInteraction<Context extends ComponentContext = ComponentContext> =\n\tContext extends ComponentContext.Button\n\t\t? ButtonInteraction\n\t\t: Context extends ComponentContext.SelectMenu\n\t\t\t? AnySelectMenuInteraction\n\t\t\t: Context extends ComponentContext.Modal\n\t\t\t\t? ModalSubmitInteraction\n\t\t\t\t: ComponentInteraction;\n\n/**\n * Trivious component\n * @param context The component context\n * @param identifier The unique identifier inside the custom id\n * @param flags The component flags\n * @param execute Component handler\n */\nexport interface Component<Context extends ComponentContext = ComponentContext> {\n\t/**\n\t * @deprecated Use context instead\n\t */\n\tcomponent?: Context;\n\tcontext: Context;\n\tidentifier: string;\n\tflags?: ComponentFlags[];\n\tpermissions?: CommandPermissionValues;\n\texecute: (\n\t\tclient: TriviousClient,\n\t\tinteraction: ContextualComponentInteraction<Context>\n\t) => Promise<void>;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-BY9Ncpz7.js';
1
+ import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,3 +1,4 @@
1
+ import { ComponentContext } from '../../shared/typings.js';
1
2
  import { TriviousError } from '../../utility/errors.js';
2
3
  import { importFile } from '../../utility/functions.js';
3
4
  import { existsSync, promises } from 'fs';
@@ -14,7 +15,12 @@ async function registerComponents(client, directory) {
14
15
  const component = await importFile(file);
15
16
  if (!component || !("component" in component && "identifier" in component && "execute" in component))
16
17
  continue;
17
- client.stores.components.set(component.identifier, component);
18
+ const contextIdentifier = component.context.toString() + component.identifier;
19
+ if (client.stores.components.get(contextIdentifier))
20
+ console.warn(
21
+ `[Trivious] Component identifier '${component.identifier}' with the context '${ComponentContext[component.context]}' has a duplicate and has been overridden`
22
+ );
23
+ client.stores.components.set(contextIdentifier, component);
18
24
  }
19
25
  }
20
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/components/registry.components.ts"],"names":["fs"],"mappings":";;;;;AAMA,eAAO,kBAAA,CAA0C,QAAwB,SAAA,EAAmB;AAC3F,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,oDAAoD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC7D;AAAA,KACD;AAED,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,SAAA,GAAY,MAAM,UAAA,CAAsB,IAAI,CAAA;AAClD,IAAA,IACC,CAAC,SAAA,IACD,EAAE,eAAe,SAAA,IAAa,YAAA,IAAgB,aAAa,SAAA,IAAa,SAAA,CAAA;AAExE,MAAA;AAED,IAAA,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,SAAA,CAAU,YAAY,SAAS,CAAA;AAAA,EAC7D;AACD","file":"registry.components.js","sourcesContent":["import { Component, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport default async function registerComponents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register components; passed directory '${directory} does not exist!'`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst component = await importFile<Component>(file);\n\t\tif (\n\t\t\t!component ||\n\t\t\t!(\"component\" in component && \"identifier\" in component && \"execute\" in component)\n\t\t)\n\t\t\tcontinue;\n\n\t\tclient.stores.components.set(component.identifier, component);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/components/registry.components.ts"],"names":["fs"],"mappings":";;;;;;AAMA,eAAO,kBAAA,CAA0C,QAAwB,SAAA,EAAmB;AAC3F,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,oDAAoD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC7D;AAAA,KACD;AAED,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,SAAA,GAAY,MAAM,UAAA,CAAsB,IAAI,CAAA;AAClD,IAAA,IACC,CAAC,SAAA,IACD,EAAE,eAAe,SAAA,IAAa,YAAA,IAAgB,aAAa,SAAA,IAAa,SAAA,CAAA;AAExE,MAAA;AAED,IAAA,MAAM,iBAAA,GAAoB,SAAA,CAAU,OAAA,CAAQ,QAAA,KAAa,SAAA,CAAU,UAAA;AACnE,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,iBAAiB,CAAA;AACjD,MAAA,OAAA,CAAQ,IAAA;AAAA,QACP,oCAAoC,SAAA,CAAU,UAAU,uBAAuB,gBAAA,CAAiB,SAAA,CAAU,OAAO,CAAC,CAAA,yCAAA;AAAA,OACnH;AAED,IAAA,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,GAAA,CAAI,iBAAA,EAAmB,SAAS,CAAA;AAAA,EAC1D;AACD","file":"registry.components.js","sourcesContent":["import { Component, ComponentContext, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport default async function registerComponents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register components; passed directory '${directory} does not exist!'`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst component = await importFile<Component>(file);\n\t\tif (\n\t\t\t!component ||\n\t\t\t!(\"component\" in component && \"identifier\" in component && \"execute\" in component)\n\t\t)\n\t\t\tcontinue;\n\n\t\tconst contextIdentifier = component.context.toString() + component.identifier;\n\t\tif (client.stores.components.get(contextIdentifier))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Component identifier '${component.identifier}' with the context '${ComponentContext[component.context]}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.components.set(contextIdentifier, component);\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import '../client/client.types.js';
2
- import { e as ComponentContext } from '../../modules.types-BY9Ncpz7.js';
2
+ import { e as ComponentContext } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../permissions/permissions.types.js';
4
4
  import 'discord.js';
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { ComponentCustomId } from './customid.types.js';
2
2
  import '../client/client.types.js';
3
3
  import 'discord.js';
4
- import '../../modules.types-BY9Ncpz7.js';
4
+ import '../../modules.types-lYoNHt-m.js';
5
5
  import '../permissions/permissions.types.js';
6
6
 
7
7
  declare const customId: {
@@ -0,0 +1,19 @@
1
+ import { E as Event } from '../../modules.types-lYoNHt-m.js';
2
+ import 'discord.js';
3
+ import '../client/client.types.js';
4
+ import '../permissions/permissions.types.js';
5
+
6
+ /**
7
+ * Create an event handler
8
+ * @param data Event data
9
+ * @returns Event
10
+ */
11
+ declare function createEvent(data: Event): Event;
12
+ /**
13
+ * Create an event handler that runs once
14
+ * @param data Event data
15
+ * @returns Event
16
+ */
17
+ declare function createOnceEvent(data: Omit<Event, "once">): Event;
18
+
19
+ export { createEvent, createOnceEvent };
@@ -0,0 +1,13 @@
1
+ function createEvent(data) {
2
+ return data;
3
+ }
4
+ function createOnceEvent(data) {
5
+ return {
6
+ once: true,
7
+ ...data
8
+ };
9
+ }
10
+
11
+ export { createEvent, createOnceEvent };
12
+ //# sourceMappingURL=builders.events.js.map
13
+ //# sourceMappingURL=builders.events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/features/events/builders.events.ts"],"names":[],"mappings":"AAOO,SAAS,YAAY,IAAA,EAAoB;AAC/C,EAAA,OAAO,IAAA;AACR;AAOO,SAAS,gBAAgB,IAAA,EAAkC;AACjE,EAAA,OAAO;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,GAAG;AAAA,GACJ;AACD","file":"builders.events.js","sourcesContent":["import { Event } from \"#typings\";\n\n/**\n * Create an event handler\n * @param data Event data\n * @returns Event\n */\nexport function createEvent(data: Event): Event {\n\treturn data;\n}\n\n/**\n * Create an event handler that runs once\n * @param data Event data\n * @returns Event\n */\nexport function createOnceEvent(data: Omit<Event, \"once\">): Event {\n\treturn {\n\t\tonce: true,\n\t\t...data,\n\t} satisfies Event;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
- export { E as Event } from '../../modules.types-BY9Ncpz7.js';
2
+ export { E as Event } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../../modules.types-BY9Ncpz7.js';
1
+ import { T as TriviousClient } from '../../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../../client/client.types.js';
4
4
  import '../../permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { T as TriviousClient } from '../../../modules.types-BY9Ncpz7.js';
2
+ import { T as TriviousClient } from '../../../modules.types-lYoNHt-m.js';
3
3
  import '../../client/client.types.js';
4
4
  import '../../permissions/permissions.types.js';
5
5
 
@@ -57,6 +57,8 @@ var interactionCreate_default = {
57
57
  }
58
58
  } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) {
59
59
  const { context, identifier, tags } = customId.decode(interaction.customId);
60
+ const identContext = identifier.slice(0, 1);
61
+ if (context !== Number(identContext)) return;
60
62
  if (context === ComponentContext.Button && !(interaction instanceof ButtonInteraction))
61
63
  return;
62
64
  if (context === ComponentContext.Modal && !(interaction instanceof ModalSubmitInteraction))
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"names":["subcommand"],"mappings":";;;;;;AAuBA,SAAS,sCAAA,CACR,MAAA,EACA,OAAA,EACA,WAAA,EAIoB;AACpB,EAAA,IAAI,EAAE,aAAA,IAAiB,OAAA,CAAA,EAAU,OAAO,CAAC,OAAO,wCAAwC,CAAA;AACxF,EAAA,IAAI,CAAC,WAAA,CAAY,kBAAA,IAAsB,OAAO,CAAC,OAAO,wCAAwC,CAAA;AA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A,EAAY,IAAA,KAAS,QAAA,CAAS,MAAA,CAAO,YAAY,QAAQ,CAAA;AAE1E,MAAA,IAAI,OAAA,KAAY,gBAAA,CAAiB,MAAA,IAAU,EAAE,WAAA,YAAuB,iBAAA,CAAA;AACnE,QAAA;AACD,MAAA,IAAI,OAAA,KAAY,gBAAA,CAAiB,KAAA,IAAS,EAAE,WAAA,YAAuB,sBAAA,CAAA;AAClE,QAAA;AACD,MAAA,IAAI,IAAA,IAAQ,IAAA,CAAK,QAAA,CAAS,SAAS,CAAA,EAAG;AAEtC,MAAA,MAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,IAAI,UAAU,CAAA;AAEzD,MAAA,IAAI,CAAC,SAAA,EAAW;AACf,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,4DAAA,EAA6D;AAAA,UACtF,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,aAAA,GAAgB,mBAAA;AAAA,QACrB,MAAA;AAAA,QACA,SAAA;AAAA,QACA,WAAA,CAAY;AAAA,OACb;AACA,MAAA,IAAI,CAAC,aAAA,EAAe;AACnB,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,kDAAA,EAAmD;AAAA,UAC5E,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,SAAA,CAAU,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import {\n\tComponentContext,\n\tSlashCommandData,\n\tTriviousClient,\n\ttype ContextCommandData,\n\ttype Event,\n} from \"#typings\";\nimport {\n\tApplicationCommandType,\n\tButtonInteraction,\n\tChatInputCommandInteraction,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport { handleSlashCommand, interactionReply } from \"src/features/commands/methods.commands.js\";\nimport customId from \"src/features/customId/methods.customid.js\";\nimport { canMemberRunCommand } from \"src/features/permissions/methods.permissions.js\";\n\n/**\n * Check if the command is a subcommand and validate whether the member can run the command based on subcommand permissions\n */\nfunction validateMemberPermissionsForSubcommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData | ContextCommandData,\n\tinteraction:\n\t\t| ChatInputCommandInteraction\n\t\t| MessageContextMenuCommandInteraction\n\t\t| UserContextMenuCommandInteraction\n): [boolean, string] {\n\tif (!(\"subcommands\" in command)) return [false, \"Cannot validate subcommand permissions\"];\n\tif (!interaction.isChatInputCommand()) return [false, \"Cannot validate subcommand permissions\"];\n\n\tconst { options } = interaction;\n\n\tconst subcommandName = options.getSubcommand(false);\n\tconst groupName = options.getSubcommandGroup(false);\n\tif (!subcommandName) return [false, \"Cannot validate subcommand permissions\"];\n\n\tif (groupName) {\n\t\tconst group = command.subcommandGroups?.get(groupName);\n\t\tif (!group) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\tconst subcommand = group.subcommands.get(subcommandName);\n\t\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n\t}\n\n\tconst subcommand = command.subcommands?.get(subcommandName);\n\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n}\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\tconst subcommandPerms = validateMemberPermissionsForSubcommand(client, command, interaction);\n\t\t\tconst commandPerms = canMemberRunCommand(client, command, interaction.member as GuildMember);\n\t\t\tconst hasPermission = subcommandPerms[0] && commandPerms[0] ? true : false;\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: {\n\t\t\t\t\t\tcontent: `You do not have permission to run this command`,\n\t\t\t\t\t},\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\tconst hasPermission = canMemberRunCommand(\n\t\t\t\tclient,\n\t\t\t\tcomponent,\n\t\t\t\tinteraction.member as GuildMember\n\t\t\t);\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"You do not have permission to use this component\" },\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"]}
1
+ {"version":3,"sources":["../../../../src/features/events/presets/interactionCreate.ts"],"names":["subcommand"],"mappings":";;;;;;AAuBA,SAAS,sCAAA,CACR,MAAA,EACA,OAAA,EACA,WAAA,EAIoB;AACpB,EAAA,IAAI,EAAE,aAAA,IAAiB,OAAA,CAAA,EAAU,OAAO,CAAC,OAAO,wCAAwC,CAAA;AACxF,EAAA,IAAI,CAAC,WAAA,CAAY,kBAAA,IAAsB,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAE9F,EAAA,MAAM,EAAE,SAAQ,GAAI,WAAA;AAEpB,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,aAAA,CAAc,KAAK,CAAA;AAClD,EAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,kBAAA,CAAmB,KAAK,CAAA;AAClD,EAAA,IAAI,CAAC,cAAA,EAAgB,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAE5E,EAAA,IAAI,SAAA,EAAW;AACd,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,gBAAA,EAAkB,GAAA,CAAI,SAAS,CAAA;AACrD,IAAA,IAAI,CAAC,KAAA,EAAO,OAAO,CAAC,OAAO,wCAAwC,CAAA;AAEnE,IAAA,MAAMA,WAAAA,GAAa,KAAA,CAAM,WAAA,CAAY,GAAA,CAAI,cAAc,CAAA;AACvD,IAAA,IAAI,CAACA,WAAAA,EAAY,OAAO,CAA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A;AAEzD,MAAA,IAAI,CAAC,SAAA,EAAW;AACf,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,4DAAA,EAA6D;AAAA,UACtF,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AAEA,MAAA,MAAM,aAAA,GAAgB,mBAAA;AAAA,QACrB,MAAA;AAAA,QACA,SAAA;AAAA,QACA,WAAA,CAAY;AAAA,OACb;AACA,MAAA,IAAI,CAAC,aAAA,EAAe;AACnB,QAAA,MAAM,gBAAA,CAAiB;AAAA,UACtB,WAAA;AAAA,UACA,YAAA,EAAc,EAAE,OAAA,EAAS,kDAAA,EAAmD;AAAA,UAC5E,KAAA,EAAO,CAAC,gBAAgB;AAAA,SACxB,CAAA;AACD,QAAA;AAAA,MACD;AACA,MAAA,MAAM,SAAA,CAAU,OAAA,CAAQ,MAAA,EAAQ,WAAW,CAAA;AAAA,IAC5C;AAAA,EACD;AACD","file":"interactionCreate.js","sourcesContent":["import {\n\tComponentContext,\n\tSlashCommandData,\n\tTriviousClient,\n\ttype ContextCommandData,\n\ttype Event,\n} from \"#typings\";\nimport {\n\tApplicationCommandType,\n\tButtonInteraction,\n\tChatInputCommandInteraction,\n\tGuildMember,\n\tMessageContextMenuCommandInteraction,\n\tModalSubmitInteraction,\n\tUserContextMenuCommandInteraction,\n} from \"discord.js\";\nimport { handleSlashCommand, interactionReply } from \"src/features/commands/methods.commands.js\";\nimport customId from \"src/features/customId/methods.customid.js\";\nimport { canMemberRunCommand } from \"src/features/permissions/methods.permissions.js\";\n\n/**\n * Check if the command is a subcommand and validate whether the member can run the command based on subcommand permissions\n */\nfunction validateMemberPermissionsForSubcommand(\n\tclient: TriviousClient,\n\tcommand: SlashCommandData | ContextCommandData,\n\tinteraction:\n\t\t| ChatInputCommandInteraction\n\t\t| MessageContextMenuCommandInteraction\n\t\t| UserContextMenuCommandInteraction\n): [boolean, string] {\n\tif (!(\"subcommands\" in command)) return [false, \"Cannot validate subcommand permissions\"];\n\tif (!interaction.isChatInputCommand()) return [false, \"Cannot validate subcommand permissions\"];\n\n\tconst { options } = interaction;\n\n\tconst subcommandName = options.getSubcommand(false);\n\tconst groupName = options.getSubcommandGroup(false);\n\tif (!subcommandName) return [false, \"Cannot validate subcommand permissions\"];\n\n\tif (groupName) {\n\t\tconst group = command.subcommandGroups?.get(groupName);\n\t\tif (!group) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\tconst subcommand = group.subcommands.get(subcommandName);\n\t\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\t\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n\t}\n\n\tconst subcommand = command.subcommands?.get(subcommandName);\n\tif (!subcommand) return [false, \"Cannot validate subcommand permissions\"];\n\n\treturn canMemberRunCommand(client, subcommand, interaction.member as GuildMember);\n}\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\tconst subcommandPerms = validateMemberPermissionsForSubcommand(client, command, interaction);\n\t\t\tconst commandPerms = canMemberRunCommand(client, command, interaction.member as GuildMember);\n\t\t\tconst hasPermission = subcommandPerms[0] && commandPerms[0] ? true : false;\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: {\n\t\t\t\t\t\tcontent: `You do not have permission to run this command`,\n\t\t\t\t\t},\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\t\t\tconst identContext = identifier.slice(0, 1);\n\t\t\tif (context !== Number(identContext)) return;\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\tconst hasPermission = canMemberRunCommand(\n\t\t\t\tclient,\n\t\t\t\tcomponent,\n\t\t\t\tinteraction.member as GuildMember\n\t\t\t);\n\t\t\tif (!hasPermission) {\n\t\t\t\tawait interactionReply({\n\t\t\t\t\tinteraction,\n\t\t\t\t\treplyPayload: { content: \"You do not have permission to use this component\" },\n\t\t\t\t\tflags: [\"EphemeralReply\"],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait component.execute(client, interaction);\n\t\t}\n\t},\n} satisfies Event<\"interactionCreate\">;\n"]}
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-BY9Ncpz7.js';
1
+ import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -36,6 +36,8 @@ async function registerEvents(client, directory) {
36
36
  for await (const file of files) {
37
37
  const event = await parseEvent(file);
38
38
  if (!event) continue;
39
+ if (client.stores.events.get(event.name))
40
+ console.warn(`[Trivious] Event '${event.name}' has a duplicate and has been overridden`);
39
41
  client.stores.events.set(event.name, event);
40
42
  }
41
43
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/events/registry.events.ts"],"names":["fs"],"mappings":";;;;;AAOA,eAAe,iBAAiB,MAAA,EAAwB;AACvD,EAAA,MAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,MAAA,CAAA,IAAA,CAAY,SAAS,SAAS,CAAA;AAC7D,EAAA,IAAI,CAAC,UAAA,CAAW,SAAS,CAAA,EAAG;AAE5B,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,QAAQ,CAAC,CAAA;AAC/C,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,KAAA,GAAQ,MAAM,UAAA,CAAW,IAAI,CAAA;AACnC,IAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,IAAA,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,EAC3C;AACD;AAEA,eAAe,WAAW,IAAA,EAAc;AACvC,EAAA,MAAM,KAAA,GAAQ,MAAM,UAAA,CAAkB,IAAI,CAAA;AAC1C,EAAA,IAAI,CAAC,KAAA,IAAS,EAAE,UAAU,KAAA,IAAS,SAAA,IAAa,QAAQ,OAAO,IAAA;AAE/D,EAAA,OAAO,KAAA;AACR;AAEA,eAAsB,WAAW,MAAA,EAAwB;AACxD,EAAA,KAAA,MAAW,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,QAAO,EAAG;AAClD,IAAA,MAAM,OAAA,GAAU,IAAI,IAAA,KACnB,KAAK,MAAM,OAAA,CAAQ,MAAA,EAAQ,GAAG,IAAI,CAAA;AAEnC,IAAA,IAAI,MAAM,IAAA,EAAM,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,MAAM,OAAO,CAAA;AAAA,SAC1C,MAAA,CAAO,EAAA,CAAG,KAAA,CAAM,IAAA,EAAM,OAAO,CAAA;AAAA,EACnC;AACD;AAEA,eAAO,cAAA,CAAsC,QAAwB,SAAA,EAAmB;AACvF,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,gDAAgD,SAAS,CAAA,iBAAA,CAAA;AAAA,MACzD;AAAA,KACD;AAED,EAAA,MAAM,iBAAiB,MAAM,CAAA;AAE7B,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,KAAA,GAAQ,MAAM,UAAA,CAAW,IAAI,CAAA;AACnC,IAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,IAAA,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,EAC3C;AACD","file":"registry.events.js","sourcesContent":["import { Event, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { ClientEvents } from \"discord.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport path, { join } from \"path\";\n\nasync function loadPresetEvents(client: TriviousClient) {\n\tconst directory = path.resolve(import.meta.dirname, \"presets\");\n\tif (!existsSync(directory)) return;\n\n\tconst files = fs.glob(join(directory, \"./*.js\"));\n\tfor await (const file of files) {\n\t\tconst event = await parseEvent(file);\n\t\tif (!event) continue;\n\n\t\tclient.stores.events.set(event.name, event);\n\t}\n}\n\nasync function parseEvent(file: string) {\n\tconst event = await importFile<Event>(file);\n\tif (!event || !(\"name\" in event && \"execute\" in event)) return null;\n\n\treturn event;\n}\n\nexport async function bindEvents(client: TriviousClient) {\n\tfor (const event of client.stores.events.values()) {\n\t\tconst handler = (...args: ClientEvents[typeof event.name]) =>\n\t\t\tvoid event.execute(client, ...args);\n\n\t\tif (event.once) client.once(event.name, handler);\n\t\telse client.on(event.name, handler);\n\t}\n}\n\nexport default async function registerEvents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register events; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tawait loadPresetEvents(client);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst event = await parseEvent(file);\n\t\tif (!event) continue;\n\n\t\tclient.stores.events.set(event.name, event);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/events/registry.events.ts"],"names":["fs"],"mappings":";;;;;AAOA,eAAe,iBAAiB,MAAA,EAAwB;AACvD,EAAA,MAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,MAAA,CAAA,IAAA,CAAY,SAAS,SAAS,CAAA;AAC7D,EAAA,IAAI,CAAC,UAAA,CAAW,SAAS,CAAA,EAAG;AAE5B,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,QAAQ,CAAC,CAAA;AAC/C,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,KAAA,GAAQ,MAAM,UAAA,CAAW,IAAI,CAAA;AACnC,IAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,IAAA,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAA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AAQ,IAAA,CAAK,CAAA,kBAAA,EAAqB,KAAA,CAAM,IAAI,CAAA,yCAAA,CAA2C,CAAA;AAExF,IAAA,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,EAC3C;AACD","file":"registry.events.js","sourcesContent":["import { Event, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { ClientEvents } from \"discord.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport path, { join } from \"path\";\n\nasync function loadPresetEvents(client: TriviousClient) {\n\tconst directory = path.resolve(import.meta.dirname, \"presets\");\n\tif (!existsSync(directory)) return;\n\n\tconst files = fs.glob(join(directory, \"./*.js\"));\n\tfor await (const file of files) {\n\t\tconst event = await parseEvent(file);\n\t\tif (!event) continue;\n\n\t\tclient.stores.events.set(event.name, event);\n\t}\n}\n\nasync function parseEvent(file: string) {\n\tconst event = await importFile<Event>(file);\n\tif (!event || !(\"name\" in event && \"execute\" in event)) return null;\n\n\treturn event;\n}\n\nexport async function bindEvents(client: TriviousClient) {\n\tfor (const event of client.stores.events.values()) {\n\t\tconst handler = (...args: ClientEvents[typeof event.name]) =>\n\t\t\tvoid event.execute(client, ...args);\n\n\t\tif (event.once) client.once(event.name, handler);\n\t\telse client.on(event.name, handler);\n\t}\n}\n\nexport default async function registerEvents(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register events; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tawait loadPresetEvents(client);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst event = await parseEvent(file);\n\t\tif (!event) continue;\n\n\t\tif (client.stores.events.get(event.name))\n\t\t\tconsole.warn(`[Trivious] Event '${event.name}' has a duplicate and has been overridden`);\n\n\t\tclient.stores.events.set(event.name, event);\n\t}\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { M as Module } from '../../modules.types-lYoNHt-m.js';
2
+ import 'discord.js';
3
+ import '../client/client.types.js';
4
+ import '../permissions/permissions.types.js';
5
+
6
+ /**
7
+ * Create a module
8
+ * @param data Module data
9
+ * @returns Module
10
+ */
11
+ declare function createModule(data: Module): Module;
12
+
13
+ export { createModule };
@@ -0,0 +1,7 @@
1
+ function createModule(data) {
2
+ return data;
3
+ }
4
+
5
+ export { createModule };
6
+ //# sourceMappingURL=builders.modules.js.map
7
+ //# sourceMappingURL=builders.modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/features/modules/builders.modules.ts"],"names":[],"mappings":"AAOO,SAAS,aAAa,IAAA,EAAc;AAC1C,EAAA,OAAO,IAAA;AACR","file":"builders.modules.js","sourcesContent":["import { Module } from \"#typings\";\n\n/**\n * Create a module\n * @param data Module data\n * @returns Module\n */\nexport function createModule(data: Module) {\n\treturn data;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import 'discord.js';
2
- export { M as Module } from '../../modules.types-BY9Ncpz7.js';
2
+ export { M as Module } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,4 +1,4 @@
1
- import { T as TriviousClient } from '../../modules.types-BY9Ncpz7.js';
1
+ import { T as TriviousClient } from '../../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../client/client.types.js';
4
4
  import '../permissions/permissions.types.js';
@@ -1,7 +1,7 @@
1
- import { existsSync, promises } from 'fs';
2
- import { join } from 'path';
3
1
  import { TriviousError } from '../../utility/errors.js';
4
2
  import { importFile } from '../../utility/functions.js';
3
+ import { existsSync, promises } from 'fs';
4
+ import { join } from 'path';
5
5
 
6
6
  async function bindModules(client) {
7
7
  for (const moduleData of client.stores.modules.values()) {
@@ -21,6 +21,10 @@ async function registerModules(client, directory) {
21
21
  for await (const file of files) {
22
22
  const moduleData = await importFile(file);
23
23
  if (!moduleData || !("name" in moduleData && "events" in moduleData)) continue;
24
+ if (client.stores.events.get(moduleData.name))
25
+ console.warn(
26
+ `[Trivious] Module '${moduleData.name}' has a duplicate and has been overridden`
27
+ );
24
28
  client.stores.modules.set(moduleData.name, moduleData);
25
29
  }
26
30
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/modules/registry.modules.ts"],"names":["fs"],"mappings":";;;;;AAMA,eAAsB,YAAY,MAAA,EAAwB;AACzD,EAAA,KAAA,MAAW,UAAA,IAAc,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,QAAO,EAAG;AACxD,IAAA,KAAA,MAAW,CAAC,MAAM,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,UAAA,CAAW,MAAM,CAAA,EAAG;AAChE,MAAA,MAAM,WAAW,CAAA,GAAI,IAAA,KACpB,KAAM,OAAA,CAAgE,MAAA,EAAQ,GAAG,IAAI,CAAA;AAEtF,MAAA,MAAA,CAAO,EAAA,CAAG,MAAM,QAAQ,CAAA;AAAA,IACzB;AAAA,EACD;AACD;AAEA,eAAO,eAAA,CAAuC,QAAwB,SAAA,EAAmB;AACxF,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,iDAAiD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC1D;AAAA,KACD;AAED,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,UAAA,GAAa,MAAM,UAAA,CAAmB,IAAI,CAAA;AAChD,IAAA,IAAI,CAAC,UAAA,IAAc,EAAE,MAAA,IAAU,UAAA,IAAc,YAAY,UAAA,CAAA,EAAa;AAEtE,IAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAW,MAAM,UAAU,CAAA;AAAA,EACtD;AACD","file":"registry.modules.js","sourcesContent":["import { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\nimport { Module, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\n\nexport async function bindModules(client: TriviousClient) {\n\tfor (const moduleData of client.stores.modules.values()) {\n\t\tfor (const [name, handler] of Object.entries(moduleData.events)) {\n\t\t\tconst listener = (...args: unknown[]) =>\n\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\n\t\t\tclient.on(name, listener);\n\t\t}\n\t}\n}\n\nexport default async function registerModules(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register modules; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst moduleData = await importFile<Module>(file);\n\t\tif (!moduleData || !(\"name\" in moduleData && \"events\" in moduleData)) continue;\n\n\t\tclient.stores.modules.set(moduleData.name, moduleData);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/features/modules/registry.modules.ts"],"names":["fs"],"mappings":";;;;;AAMA,eAAsB,YAAY,MAAA,EAAwB;AACzD,EAAA,KAAA,MAAW,UAAA,IAAc,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,QAAO,EAAG;AACxD,IAAA,KAAA,MAAW,CAAC,MAAM,OAAO,CAAA,IAAK,OAAO,OAAA,CAAQ,UAAA,CAAW,MAAM,CAAA,EAAG;AAChE,MAAA,MAAM,WAAW,CAAA,GAAI,IAAA,KACpB,KAAM,OAAA,CAAgE,MAAA,EAAQ,GAAG,IAAI,CAAA;AAEtF,MAAA,MAAA,CAAO,EAAA,CAAG,MAAM,QAAQ,CAAA;AAAA,IACzB;AAAA,EACD;AACD;AAEA,eAAO,eAAA,CAAuC,QAAwB,SAAA,EAAmB;AACxF,EAAA,IAAI,CAAC,WAAW,SAAS,CAAA;AACxB,IAAA,MAAM,IAAI,aAAA;AAAA,MACT,iDAAiD,SAAS,CAAA,iBAAA,CAAA;AAAA,MAC1D;AAAA,KACD;AAED,EAAA,MAAM,QAAQA,QAAA,CAAG,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,SAAS,CAAC,CAAA;AAChD,EAAA,WAAA,MAAiB,QAAQ,KAAA,EAAO;AAC/B,IAAA,MAAM,UAAA,GAAa,MAAM,UAAA,CAAmB,IAAI,CAAA;AAChD,IAAA,IAAI,CAAC,UAAA,IAAc,EAAE,MAAA,IAAU,UAAA,IAAc,YAAY,UAAA,CAAA,EAAa;AAEtE,IAAA,IAAI,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,WAAW,IAAI,CAAA;AAC3C,MAAA,OAAA,CAAQ,IAAA;AAAA,QACP,CAAA,mBAAA,EAAsB,WAAW,IAAI,CAAA,yCAAA;AAAA,OACtC;AAED,IAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,UAAA,CAAW,MAAM,UAAU,CAAA;AAAA,EACtD;AACD","file":"registry.modules.js","sourcesContent":["import { Module, TriviousClient } from \"#typings\";\nimport { TriviousError } from \"#utility/errors.js\";\nimport { importFile } from \"#utility/functions.js\";\nimport { existsSync, promises as fs } from \"fs\";\nimport { join } from \"path\";\n\nexport async function bindModules(client: TriviousClient) {\n\tfor (const moduleData of client.stores.modules.values()) {\n\t\tfor (const [name, handler] of Object.entries(moduleData.events)) {\n\t\t\tconst listener = (...args: unknown[]) =>\n\t\t\t\tvoid (handler as (client: TriviousClient, ...args: unknown[]) => any)(client, ...args);\n\n\t\t\tclient.on(name, listener);\n\t\t}\n\t}\n}\n\nexport default async function registerModules(client: TriviousClient, directory: string) {\n\tif (!existsSync(directory))\n\t\tthrow new TriviousError(\n\t\t\t`Could not register modules; passed directory '${directory}' does not exist!`,\n\t\t\t\"Nonexistant directory passed\"\n\t\t);\n\n\tconst files = fs.glob(join(directory, \"**/*.js\"));\n\tfor await (const file of files) {\n\t\tconst moduleData = await importFile<Module>(file);\n\t\tif (!moduleData || !(\"name\" in moduleData && \"events\" in moduleData)) continue;\n\n\t\tif (client.stores.events.get(moduleData.name))\n\t\t\tconsole.warn(\n\t\t\t\t`[Trivious] Module '${moduleData.name}' has a duplicate and has been overridden`\n\t\t\t);\n\n\t\tclient.stores.modules.set(moduleData.name, moduleData);\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { GuildMember, User } from 'discord.js';
2
- import { T as TriviousClient, a as BaseCommandData, d as Component } from '../../modules.types-BY9Ncpz7.js';
2
+ import { T as TriviousClient, a as BaseCommandData, d as Component } from '../../modules.types-lYoNHt-m.js';
3
3
  import '../client/client.types.js';
4
4
  import './permissions.types.js';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- export { createActionRow, createEmbed } from './features/builders/utility.builders.js';
2
- export { createMessageContextCommand, createSlashCommand, createSlashSubcommand, createSlashSubcommandGroup, createSubcommand, createSubcommandGroup, createUserContextCommand } from './features/commands/builders.commands.js';
3
- export { handleSlashCommand, interactionReply } from './features/commands/methods.commands.js';
4
- export { default as customId } from './features/customId/methods.customid.js';
5
1
  export { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure } from './features/client/client.types.js';
6
- export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction, h as ContextCommandData, E as Event, M as Module, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData, T as TriviousClient } from './modules.types-BY9Ncpz7.js';
2
+ export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction, h as ContextCommandData, E as Event, M as Module, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData, T as TriviousClient } from './modules.types-lYoNHt-m.js';
7
3
  export { ComponentCustomId, ComponentTag } from './features/customId/customid.types.js';
8
4
  export { CommandPermissionValues } from './features/permissions/permissions.types.js';
5
+ export { createActionRow, createEmbed } from './features/builders/utility.builders.js';
6
+ export { handleSlashCommand, interactionReply } from './features/commands/methods.commands.js';
7
+ export { default as customId } from './features/customId/methods.customid.js';
8
+ export { createMessageContextCommand, createSlashCommand, createSlashSubcommand, createSlashSubcommandGroup, createSubcommand, createSubcommandGroup, createUserContextCommand } from './features/commands/builders.commands.js';
9
+ export { createButtonComponent, createComponent, createModalComponent, createSelectMenuComponent } from './features/components/builders.components.js';
10
+ export { createEvent, createOnceEvent } from './features/events/builders.events.js';
11
+ export { createModule } from './features/modules/builders.modules.js';
9
12
  import 'discord.js';
package/dist/index.js CHANGED
@@ -1,7 +1,10 @@
1
+ export * from './shared/typings.js';
1
2
  export * from './features/builders/utility.builders.js';
2
- export * from './features/commands/builders.commands.js';
3
3
  export * from './features/commands/methods.commands.js';
4
4
  export { default as customId } from './features/customId/methods.customid.js';
5
- export * from './shared/typings.js';
5
+ export * from './features/commands/builders.commands.js';
6
+ export * from './features/components/builders.components.js';
7
+ export * from './features/events/builders.events.js';
8
+ export * from './features/modules/builders.modules.js';
6
9
  //# sourceMappingURL=index.js.map
7
10
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { Client, Collection, ApplicationCommandType, Interaction, SlashCommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandSubcommandBuilder, ChatInputCommandInteraction, SlashCommandSubcommandGroupBuilder, ContextMenuCommandBuilder, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, AnySelectMenuInteraction, ButtonInteraction, ModalSubmitInteraction, ClientEvents } from 'discord.js';
1
+ import { Client, Collection, ApplicationCommandType, Interaction, SlashCommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandSubcommandBuilder, ChatInputCommandInteraction, SlashCommandSubcommandGroupBuilder, ContextMenuCommandBuilder, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, ButtonInteraction, AnySelectMenuInteraction, ModalSubmitInteraction, ClientEvents } from 'discord.js';
2
2
  import { TriviousClientOptions } from './features/client/client.types.js';
3
3
  import { CommandPermissionValues } from './features/permissions/permissions.types.js';
4
4
 
@@ -111,19 +111,24 @@ declare enum ComponentContext {
111
111
  SelectMenu = 1,
112
112
  Modal = 2
113
113
  }
114
+ type ContextualComponentInteraction<Context extends ComponentContext = ComponentContext> = Context extends ComponentContext.Button ? ButtonInteraction : Context extends ComponentContext.SelectMenu ? AnySelectMenuInteraction : Context extends ComponentContext.Modal ? ModalSubmitInteraction : ComponentInteraction;
114
115
  /**
115
116
  * Trivious component
116
- * @param component The component type
117
+ * @param context The component context
117
118
  * @param identifier The unique identifier inside the custom id
118
119
  * @param flags The component flags
119
120
  * @param execute Component handler
120
121
  */
121
- interface Component {
122
- component: ComponentContext;
122
+ interface Component<Context extends ComponentContext = ComponentContext> {
123
+ /**
124
+ * @deprecated Use context instead
125
+ */
126
+ component?: Context;
127
+ context: Context;
123
128
  identifier: string;
124
129
  flags?: ComponentFlags[];
125
130
  permissions?: CommandPermissionValues;
126
- execute: (client: TriviousClient, interaction: ComponentInteraction) => Promise<void>;
131
+ execute: (client: TriviousClient, interaction: ContextualComponentInteraction<Context>) => Promise<void>;
127
132
  }
128
133
 
129
134
  interface Event<K extends keyof ClientEvents = keyof ClientEvents> {
@@ -2,7 +2,7 @@ import registerCommands from '../features/commands/registry.commands.js';
2
2
  import registerComponents from '../features/components/registry.components.js';
3
3
  import registerEvents, { bindEvents } from '../features/events/registry.events.js';
4
4
  import registerModules, { bindModules } from '../features/modules/registry.modules.js';
5
- import '../modules.types-BY9Ncpz7.js';
5
+ import '../modules.types-lYoNHt-m.js';
6
6
  import 'discord.js';
7
7
  import '../features/client/client.types.js';
8
8
  import '../features/permissions/permissions.types.js';
@@ -1,5 +1,5 @@
1
1
  export { CommandHashConfiguration, FeatureBasedStructure, TriviousClientCredentials, TriviousClientOptions, TriviousStructure, TypeBasedStructure } from '../features/client/client.types.js';
2
- export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction, h as ContextCommandData, E as Event, M as Module, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData, T as TriviousClient } from '../modules.types-BY9Ncpz7.js';
2
+ export { B as BaseChatInputCommandData, a as BaseCommandData, C as ChatInputCommandContext, b as CommandFlags, c as CommandFunction, d as Component, e as ComponentContext, f as ComponentFlags, g as ComponentInteraction, h as ContextCommandData, E as Event, M as Module, S as SlashCommandData, i as SlashSubcommandData, j as SlashSubcommandGroupData, T as TriviousClient } from '../modules.types-lYoNHt-m.js';
3
3
  export { ComponentCustomId, ComponentTag } from '../features/customId/customid.types.js';
4
4
  export { CommandPermissionValues } from '../features/permissions/permissions.types.js';
5
5
  import 'discord.js';
@@ -1,4 +1,4 @@
1
- import { a as BaseCommandData, S as SlashCommandData } from '../modules.types-BY9Ncpz7.js';
1
+ import { a as BaseCommandData, S as SlashCommandData } from '../modules.types-lYoNHt-m.js';
2
2
  import 'discord.js';
3
3
  import '../features/client/client.types.js';
4
4
  import '../features/permissions/permissions.types.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trivious",
3
- "version": "2.1.13",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "discord-bot",
@@ -75,6 +75,6 @@
75
75
  "vitest": "^4.0.13"
76
76
  },
77
77
  "dependencies": {
78
- "discord.js": "^14.26.3"
78
+ "discord.js": "^14.26.4"
79
79
  }
80
80
  }