commandkit 0.1.10-dev.20231229085439 → 0.1.10-dev.20240108063947

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/index.js CHANGED
@@ -35,7 +35,16 @@ __export(src_exports, {
35
35
  createEffect: () => createEffect,
36
36
  createSignal: () => createSignal,
37
37
  defineConfig: () => defineConfig,
38
- getConfig: () => getConfig
38
+ getConfig: () => getConfig,
39
+ response: () => response,
40
+ useChannel: () => useChannel,
41
+ useClient: () => useClient,
42
+ useCommandData: () => useCommandData,
43
+ useCommandKit: () => useCommandKit,
44
+ useGuild: () => useGuild,
45
+ useInteraction: () => useInteraction,
46
+ useMember: () => useMember,
47
+ useUser: () => useUser
39
48
  });
40
49
  module.exports = __toCommonJS(src_exports);
41
50
 
@@ -126,7 +135,7 @@ async function loadCommandsWithRest(props) {
126
135
  props.type
127
136
  );
128
137
  } else {
129
- throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`));
138
+ throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`));
130
139
  }
131
140
  } else {
132
141
  props.client.once("ready", async (c) => {
@@ -150,18 +159,16 @@ async function handleLoading(client, commands, devGuildIds, reloading, type) {
150
159
  async function loadGlobalCommands(client, commands, reloading) {
151
160
  const requestBody = commands.map((cmd) => cmd.data);
152
161
  await client.application.commands.set(requestBody).catch((error) => {
153
- console.log(
162
+ throw new Error(
154
163
  colors_default.red(
155
- `\u274C Error ${reloading ? "reloading" : "loading"} global application commands.
164
+ `Error ${reloading ? "reloading" : "loading"} global application commands.
156
165
  `
157
- )
166
+ ),
167
+ error
158
168
  );
159
- throw new Error(error);
160
169
  });
161
170
  console.log(
162
- colors_default.green(
163
- `\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`
164
- )
171
+ colors_default.green(`${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`)
165
172
  );
166
173
  }
167
174
  async function loadDevCommands(client, commands, guildIds, reloading) {
@@ -169,23 +176,23 @@ async function loadDevCommands(client, commands, guildIds, reloading) {
169
176
  for (const guildId of guildIds) {
170
177
  const targetGuild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId);
171
178
  if (!targetGuild) {
172
- console.log(
173
- `Couldn't ${reloading ? "reloading" : "loading"} commands in guild "${targetGuild}" - guild doesn't exist or client isn't part of the guild.`
179
+ process.emitWarning(
180
+ `Cannot ${reloading ? "reload" : "load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.`
174
181
  );
175
182
  continue;
176
183
  }
177
184
  await targetGuild.commands.set(requestBody).catch((error) => {
178
- console.log(
185
+ throw new Error(
179
186
  colors_default.red(
180
- `\u274C Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}".
187
+ `Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}".
181
188
  `
182
- )
189
+ ),
190
+ error
183
191
  );
184
- throw new Error(error);
185
192
  });
186
193
  console.log(
187
194
  colors_default.green(
188
- `\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`
195
+ `${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`
189
196
  )
190
197
  );
191
198
  }
@@ -212,7 +219,7 @@ async function registerCommands(props) {
212
219
  if (props.client.isReady()) {
213
220
  await handleRegistration(props.client, props.commands, props.devGuildIds, props.type);
214
221
  } else {
215
- throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`));
222
+ throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`));
216
223
  }
217
224
  } else {
218
225
  props.client.once("ready", async (c) => {
@@ -241,19 +248,20 @@ async function registerGlobalCommands(client, commands) {
241
248
  );
242
249
  if (command.options?.deleted) {
243
250
  if (!targetCommand) {
244
- console.log(
251
+ process.emitWarning(
245
252
  colors_default.yellow(
246
- `\u23E9 Ignoring: Command "${command.data.name}" is globally marked as deleted.`
253
+ `Ignoring: Command "${command.data.name}" is globally marked as deleted.`
247
254
  )
248
255
  );
249
256
  } else {
250
257
  await targetCommand.delete().catch((error) => {
251
- console.log(
252
- colors_default.red(`\u274C Failed to delete command "${command.data.name}" globally.`)
258
+ throw new Error(
259
+ colors_default.red(`Failed to delete command "${command.data.name}" globally.
260
+ `),
261
+ error
253
262
  );
254
- console.error(error);
255
263
  });
256
- console.log(colors_default.green(`\u{1F6AE} Deleted command "${command.data.name}" globally.`));
264
+ console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`));
257
265
  }
258
266
  continue;
259
267
  }
@@ -261,26 +269,26 @@ async function registerGlobalCommands(client, commands) {
261
269
  const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
262
270
  if (commandsAreDifferent) {
263
271
  await targetCommand.edit(command.data).catch((error) => {
264
- console.log(
265
- colors_default.red(
266
- `\u274C Failed to edit command "${command.data.name}" globally.`
267
- )
272
+ throw new Error(
273
+ colors_default.red(`Failed to edit command "${command.data.name}" globally.
274
+ `),
275
+ error
268
276
  );
269
- console.error(error);
270
277
  });
271
- console.log(colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`));
278
+ console.log(colors_default.green(`Edited command "${command.data.name}" globally.`));
272
279
  continue;
273
280
  }
274
281
  }
275
282
  if (targetCommand)
276
283
  continue;
277
284
  await appCommandsManager.create(command.data).catch((error) => {
278
- console.log(
279
- colors_default.red(`\u274C Failed to register command "${command.data.name}" globally.`)
285
+ throw new Error(
286
+ colors_default.red(`Failed to register command "${command.data.name}" globally.
287
+ `),
288
+ error
280
289
  );
281
- console.error(error);
282
290
  });
283
- console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
291
+ console.log(colors_default.green(`Registered command "${command.data.name}" globally.`));
284
292
  }
285
293
  }
286
294
  async function registerDevCommands(client, commands, guildIds) {
@@ -288,9 +296,9 @@ async function registerDevCommands(client, commands, guildIds) {
288
296
  for (const guildId of guildIds) {
289
297
  const guild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId);
290
298
  if (!guild) {
291
- console.log(
299
+ process.emitWarning(
292
300
  colors_default.yellow(
293
- `\u23E9 Ignoring: Guild ${guildId} does not exist or client isn't in this guild.`
301
+ `Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`
294
302
  )
295
303
  );
296
304
  continue;
@@ -308,23 +316,23 @@ async function registerDevCommands(client, commands, guildIds) {
308
316
  const targetCommand = guildCommands.cache.find((cmd) => cmd.name === command.data.name);
309
317
  if (command.options?.deleted) {
310
318
  if (!targetCommand) {
311
- console.log(
319
+ process.emitWarning(
312
320
  colors_default.yellow(
313
- `\u23E9 Ignoring: Command "${command.data.name}" is marked as deleted for ${guildCommands.guild.name}.`
321
+ `Ignoring: Command "${command.data.name}" is marked as deleted in ${guildCommands.guild.name}.`
314
322
  )
315
323
  );
316
324
  } else {
317
325
  await targetCommand.delete().catch((error) => {
318
- console.log(
326
+ throw new Error(
319
327
  colors_default.red(
320
- `\u274C Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
321
- )
328
+ `Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
329
+ ),
330
+ error
322
331
  );
323
- console.error(error);
324
332
  });
325
333
  console.log(
326
334
  colors_default.green(
327
- `\u{1F6AE} Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
335
+ `Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
328
336
  )
329
337
  );
330
338
  }
@@ -334,16 +342,17 @@ async function registerDevCommands(client, commands, guildIds) {
334
342
  const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
335
343
  if (commandsAreDifferent) {
336
344
  await targetCommand.edit(command.data).catch((error) => {
337
- console.log(
345
+ throw new Error(
338
346
  colors_default.red(
339
- `\u274C Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.`
340
- )
347
+ `Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.
348
+ `
349
+ ),
350
+ error
341
351
  );
342
- console.error(error);
343
352
  });
344
353
  console.log(
345
354
  colors_default.green(
346
- `\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
355
+ `Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
347
356
  )
348
357
  );
349
358
  continue;
@@ -352,16 +361,17 @@ async function registerDevCommands(client, commands, guildIds) {
352
361
  if (targetCommand)
353
362
  continue;
354
363
  await guildCommands.create(command.data).catch((error) => {
355
- console.log(
364
+ throw new Error(
356
365
  colors_default.red(
357
- `\u274C Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.`
358
- )
366
+ `Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.
367
+ `
368
+ ),
369
+ error
359
370
  );
360
- console.error(error);
361
371
  });
362
372
  console.log(
363
373
  colors_default.green(
364
- `\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
374
+ `Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
365
375
  )
366
376
  );
367
377
  }
@@ -469,8 +479,10 @@ function permissions_default({ interaction, targetCommand }) {
469
479
  var validations_default = [devOnly_default, permissions_default];
470
480
 
471
481
  // src/handlers/command-handler/CommandHandler.ts
482
+ var import_async_hooks = require("async_hooks");
472
483
  var CommandHandler = class {
473
484
  #data;
485
+ context = null;
474
486
  constructor({ ...options }) {
475
487
  this.#data = {
476
488
  ...options,
@@ -479,20 +491,23 @@ var CommandHandler = class {
479
491
  };
480
492
  }
481
493
  async init() {
494
+ if (this.#data.enableHooks && !this.context) {
495
+ this.context = new import_async_hooks.AsyncLocalStorage();
496
+ }
482
497
  await this.#buildCommands();
483
498
  this.#buildBuiltInValidations();
484
499
  const devOnlyCommands = this.#data.commands.filter((cmd) => cmd.options?.devOnly);
485
500
  if (devOnlyCommands.length && !this.#data.devGuildIds.length) {
486
- console.log(
501
+ process.emitWarning(
487
502
  colors_default.yellow(
488
- '\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devGuildIds" have not been set.'
503
+ 'You have commands marked as "devOnly", but "devGuildIds" have not been set.'
489
504
  )
490
505
  );
491
506
  }
492
507
  if (devOnlyCommands.length && !this.#data.devUserIds.length && !this.#data.devRoleIds.length) {
493
- console.log(
508
+ process.emitWarning(
494
509
  colors_default.yellow(
495
- '\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.'
510
+ 'You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.'
496
511
  )
497
512
  );
498
513
  }
@@ -531,33 +546,33 @@ var CommandHandler = class {
531
546
  commandObj.data = importedObj.data;
532
547
  }
533
548
  if (!commandObj.data) {
534
- console.log(
549
+ process.emitWarning(
535
550
  colors_default.yellow(
536
- `\u23E9 Ignoring: Command ${compactFilePath} does not export "data".`
551
+ `Ignoring: Command file ${compactFilePath} does not export "data".`
537
552
  )
538
553
  );
539
554
  continue;
540
555
  }
541
556
  if (!commandObj.data.name) {
542
- console.log(
557
+ process.emitWarning(
543
558
  colors_default.yellow(
544
- `\u23E9 Ignoring: Command ${compactFilePath} does not export "data.name".`
559
+ `Ignoring: Command file ${compactFilePath} does not export "data.name".`
545
560
  )
546
561
  );
547
562
  continue;
548
563
  }
549
564
  if (!commandObj.run) {
550
- console.log(
565
+ process.emitWarning(
551
566
  colors_default.yellow(
552
- `\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run".`
567
+ `Ignoring: Command file ${commandObj.data.name} does not export "run".`
553
568
  )
554
569
  );
555
570
  continue;
556
571
  }
557
572
  if (typeof commandObj.run !== "function") {
558
- console.log(
573
+ process.emitWarning(
559
574
  colors_default.yellow(
560
- `\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run" as a function.`
575
+ `Ignoring: Command file ${commandObj.data.name} does not export "run" as a function.`
561
576
  )
562
577
  );
563
578
  continue;
@@ -578,6 +593,7 @@ var CommandHandler = class {
578
593
  }
579
594
  }
580
595
  handleCommands() {
596
+ const areHooksEnabled = this.#data.enableHooks;
581
597
  this.#data.client.on("interactionCreate", async (interaction) => {
582
598
  if (!interaction.isChatInputCommand() && !interaction.isContextMenuCommand() && !interaction.isAutocomplete())
583
599
  return;
@@ -590,50 +606,65 @@ var CommandHandler = class {
590
606
  const { data, options, run, autocomplete, ...rest } = targetCommand;
591
607
  if (isAutocomplete && !autocomplete)
592
608
  return;
593
- const commandObj = {
594
- data: targetCommand.data,
595
- options: targetCommand.options,
596
- ...rest
597
- };
598
- if (this.#data.validationHandler) {
599
- let canRun2 = true;
600
- for (const validationFunction of this.#data.validationHandler.validations) {
601
- const stopValidationLoop = await validationFunction({
602
- interaction,
603
- commandObj,
604
- client: this.#data.client,
605
- handler: this.#data.commandkitInstance
606
- });
607
- if (stopValidationLoop) {
608
- canRun2 = false;
609
- break;
609
+ const executor = async () => {
610
+ const commandObj = {
611
+ data: targetCommand.data,
612
+ options: targetCommand.options,
613
+ ...rest
614
+ };
615
+ if (this.#data.validationHandler) {
616
+ let canRun2 = true;
617
+ for (const validationFunction of this.#data.validationHandler.validations) {
618
+ const stopValidationLoop = await validationFunction({
619
+ interaction,
620
+ commandObj,
621
+ client: this.#data.client,
622
+ handler: this.#data.commandkitInstance
623
+ });
624
+ if (stopValidationLoop) {
625
+ canRun2 = false;
626
+ break;
627
+ }
610
628
  }
629
+ if (!canRun2)
630
+ return;
611
631
  }
612
- if (!canRun2)
632
+ let canRun = true;
633
+ if (!this.#data.skipBuiltInValidations) {
634
+ for (const validation of this.#data.builtInValidations) {
635
+ const stopValidationLoop = validation({
636
+ targetCommand,
637
+ interaction,
638
+ handlerData: this.#data
639
+ });
640
+ if (stopValidationLoop) {
641
+ canRun = false;
642
+ break;
643
+ }
644
+ }
645
+ }
646
+ if (!canRun)
613
647
  return;
614
- }
615
- let canRun = true;
616
- if (!this.#data.skipBuiltInValidations) {
617
- for (const validation of this.#data.builtInValidations) {
618
- const stopValidationLoop = validation({
619
- targetCommand,
648
+ const command = targetCommand[isAutocomplete ? "autocomplete" : "run"];
649
+ if (!areHooksEnabled) {
650
+ const context2 = {
620
651
  interaction,
621
- handlerData: this.#data
622
- });
623
- if (stopValidationLoop) {
624
- canRun = false;
625
- break;
626
- }
652
+ client: this.#data.client,
653
+ handler: this.#data.commandkitInstance
654
+ };
655
+ return await command(context2);
627
656
  }
628
- }
629
- if (!canRun)
630
- return;
631
- const context2 = {
632
- interaction,
633
- client: this.#data.client,
634
- handler: this.#data.commandkitInstance
657
+ return command();
635
658
  };
636
- await targetCommand[isAutocomplete ? "autocomplete" : "run"](context2);
659
+ if (this.context)
660
+ return this.context.run(
661
+ {
662
+ command: targetCommand.data,
663
+ interaction
664
+ },
665
+ executor
666
+ );
667
+ return executor();
637
668
  });
638
669
  }
639
670
  get commands() {
@@ -642,7 +673,9 @@ var CommandHandler = class {
642
673
  async reloadCommands(type) {
643
674
  if (!this.#data.commandsPath) {
644
675
  throw new Error(
645
- 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
676
+ colors_default.red(
677
+ 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
678
+ )
646
679
  );
647
680
  }
648
681
  this.#data.commands = [];
@@ -704,9 +737,9 @@ var EventHandler = class {
704
737
  }
705
738
  const compactFilePath = eventFilePath.split(process.cwd())[1] || eventFilePath;
706
739
  if (typeof eventFunction !== "function") {
707
- console.log(
740
+ process.emitWarning(
708
741
  colors_default.yellow(
709
- `\u23E9 Ignoring: Event ${compactFilePath} does not export a function.`
742
+ `Ignoring: Event file ${compactFilePath} does not export a function.`
710
743
  )
711
744
  );
712
745
  continue;
@@ -735,7 +768,9 @@ var EventHandler = class {
735
768
  async reloadEvents(commandHandler) {
736
769
  if (!this.#data.eventsPath) {
737
770
  throw new Error(
738
- 'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
771
+ colors_default.red(
772
+ 'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
773
+ )
739
774
  );
740
775
  }
741
776
  this.#data.events = [];
@@ -775,9 +810,9 @@ var ValidationHandler = class {
775
810
  }
776
811
  const compactFilePath = validationFilePath.split(process.cwd())[1] || validationFilePath;
777
812
  if (typeof validationFunction !== "function") {
778
- console.log(
813
+ process.emitWarning(
779
814
  colors_default.yellow(
780
- `\u23E9 Ignoring: Validation ${compactFilePath} does not export a function.`
815
+ `Ignoring: Validation file ${compactFilePath} does not export a function.`
781
816
  )
782
817
  );
783
818
  continue;
@@ -792,7 +827,9 @@ var ValidationHandler = class {
792
827
  async reloadValidations() {
793
828
  if (!this.#data.validationsPath) {
794
829
  throw new Error(
795
- 'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
830
+ colors_default.red(
831
+ 'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
832
+ )
796
833
  );
797
834
  }
798
835
  const newValidations = await this.#buildValidations();
@@ -801,8 +838,9 @@ var ValidationHandler = class {
801
838
  };
802
839
 
803
840
  // src/CommandKit.ts
804
- var CommandKit = class {
841
+ var CommandKit = class _CommandKit {
805
842
  #data;
843
+ static _instance = null;
806
844
  /**
807
845
  * Create a new command and event handler with CommandKit.
808
846
  *
@@ -819,8 +857,21 @@ var CommandKit = class {
819
857
  );
820
858
  }
821
859
  this.#data = options;
860
+ _CommandKit._instance = this;
822
861
  this.#init();
823
862
  }
863
+ /**
864
+ * Get the client attached to this CommandKit instance.
865
+ */
866
+ get client() {
867
+ return this.#data.client;
868
+ }
869
+ /**
870
+ * Get command handler instance.
871
+ */
872
+ get commandHandler() {
873
+ return this.#data.commandHandler;
874
+ }
824
875
  /**
825
876
  * (Private) Initialize CommandKit.
826
877
  */
@@ -851,7 +902,8 @@ var CommandKit = class {
851
902
  validationHandler: this.#data.validationHandler,
852
903
  skipBuiltInValidations: this.#data.skipBuiltInValidations || false,
853
904
  commandkitInstance: this,
854
- bulkRegister: this.#data.bulkRegister || false
905
+ bulkRegister: this.#data.bulkRegister || false,
906
+ enableHooks: this.#data.experimental?.hooks ?? false
855
907
  });
856
908
  await commandHandler.init();
857
909
  this.#data.commandHandler = commandHandler;
@@ -1104,6 +1156,103 @@ function createEffect(callback) {
1104
1156
  function getCurrentObserver() {
1105
1157
  return context[context.length - 1];
1106
1158
  }
1159
+
1160
+ // src/hooks/common.ts
1161
+ function getCommandKit() {
1162
+ return CommandKit._instance;
1163
+ }
1164
+ function getCommandHandler() {
1165
+ const handler = getCommandKit()?.commandHandler;
1166
+ if (!handler) {
1167
+ throw new Error("CommandKit is not initialized.");
1168
+ }
1169
+ return handler;
1170
+ }
1171
+ function getContext() {
1172
+ const info = getCommandHandler().context;
1173
+ if (!info) {
1174
+ throw new Error("Context is not available, did you forget to enable hooks?");
1175
+ }
1176
+ return info;
1177
+ }
1178
+ function prepareHookInvocationError(name) {
1179
+ return new Error(`Cannot invoke hook "${name}" outside of a command.`);
1180
+ }
1181
+
1182
+ // src/hooks/useCommandKit.ts
1183
+ function useCommandKit() {
1184
+ const kit = getCommandKit();
1185
+ if (!kit)
1186
+ throw new Error("CommandKit is not initialized.");
1187
+ return kit;
1188
+ }
1189
+
1190
+ // src/hooks/useClient.ts
1191
+ function useClient() {
1192
+ return useCommandKit().client;
1193
+ }
1194
+
1195
+ // src/hooks/useInteraction.ts
1196
+ function useInteraction() {
1197
+ const data = getContext().getStore();
1198
+ if (!data)
1199
+ throw prepareHookInvocationError("useInteraction");
1200
+ return data.interaction;
1201
+ }
1202
+
1203
+ // src/hooks/response.ts
1204
+ async function response(data) {
1205
+ const interaction = useInteraction();
1206
+ if (interaction.isAutocomplete())
1207
+ return;
1208
+ if (interaction.replied || interaction.deferred) {
1209
+ await interaction.editReply(data);
1210
+ } else if (interaction.isMessageComponent()) {
1211
+ await interaction.update(data);
1212
+ } else {
1213
+ await interaction.reply(data);
1214
+ }
1215
+ }
1216
+
1217
+ // src/hooks/useChannel.ts
1218
+ function useChannel() {
1219
+ const data = getContext().getStore();
1220
+ if (!data)
1221
+ throw prepareHookInvocationError("useChannel");
1222
+ return data.interaction.channel;
1223
+ }
1224
+
1225
+ // src/hooks/useCommandData.ts
1226
+ function useCommandData() {
1227
+ const data = getContext().getStore();
1228
+ if (!data)
1229
+ throw prepareHookInvocationError("useCommandData");
1230
+ return data.command;
1231
+ }
1232
+
1233
+ // src/hooks/useGuild.ts
1234
+ function useGuild() {
1235
+ const data = getContext().getStore();
1236
+ if (!data)
1237
+ throw prepareHookInvocationError("useGuild");
1238
+ return data.interaction.guild;
1239
+ }
1240
+
1241
+ // src/hooks/useMember.ts
1242
+ function useMember() {
1243
+ const data = getContext().getStore();
1244
+ if (!data)
1245
+ throw prepareHookInvocationError("useMember");
1246
+ return data.interaction.member;
1247
+ }
1248
+
1249
+ // src/hooks/useUser.ts
1250
+ function useUser() {
1251
+ const data = getContext().getStore();
1252
+ if (!data)
1253
+ throw prepareHookInvocationError("useUser");
1254
+ return data.interaction.user;
1255
+ }
1107
1256
  // Annotate the CommonJS export names for ESM import in node:
1108
1257
  0 && (module.exports = {
1109
1258
  ButtonKit,
@@ -1111,5 +1260,14 @@ function getCurrentObserver() {
1111
1260
  createEffect,
1112
1261
  createSignal,
1113
1262
  defineConfig,
1114
- getConfig
1263
+ getConfig,
1264
+ response,
1265
+ useChannel,
1266
+ useClient,
1267
+ useCommandData,
1268
+ useCommandKit,
1269
+ useGuild,
1270
+ useInteraction,
1271
+ useMember,
1272
+ useUser
1115
1273
  });