commandkit 0.1.10-dev.20231214182432 → 0.1.10-dev.20231229094034

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
@@ -126,7 +126,7 @@ async function loadCommandsWithRest(props) {
126
126
  props.type
127
127
  );
128
128
  } else {
129
- throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`));
129
+ throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`));
130
130
  }
131
131
  } else {
132
132
  props.client.once("ready", async (c) => {
@@ -150,18 +150,16 @@ async function handleLoading(client, commands, devGuildIds, reloading, type) {
150
150
  async function loadGlobalCommands(client, commands, reloading) {
151
151
  const requestBody = commands.map((cmd) => cmd.data);
152
152
  await client.application.commands.set(requestBody).catch((error) => {
153
- console.log(
153
+ throw new Error(
154
154
  colors_default.red(
155
- `\u274C Error ${reloading ? "reloading" : "loading"} global application commands.
155
+ `Error ${reloading ? "reloading" : "loading"} global application commands.
156
156
  `
157
- )
157
+ ),
158
+ error
158
159
  );
159
- throw new Error(error);
160
160
  });
161
161
  console.log(
162
- colors_default.green(
163
- `\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`
164
- )
162
+ colors_default.green(`${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`)
165
163
  );
166
164
  }
167
165
  async function loadDevCommands(client, commands, guildIds, reloading) {
@@ -169,23 +167,23 @@ async function loadDevCommands(client, commands, guildIds, reloading) {
169
167
  for (const guildId of guildIds) {
170
168
  const targetGuild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId);
171
169
  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.`
170
+ process.emitWarning(
171
+ `Cannot ${reloading ? "reload" : "load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.`
174
172
  );
175
173
  continue;
176
174
  }
177
175
  await targetGuild.commands.set(requestBody).catch((error) => {
178
- console.log(
176
+ throw new Error(
179
177
  colors_default.red(
180
- `\u274C Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}".
178
+ `Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}".
181
179
  `
182
- )
180
+ ),
181
+ error
183
182
  );
184
- throw new Error(error);
185
183
  });
186
184
  console.log(
187
185
  colors_default.green(
188
- `\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`
186
+ `${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`
189
187
  )
190
188
  );
191
189
  }
@@ -212,7 +210,7 @@ async function registerCommands(props) {
212
210
  if (props.client.isReady()) {
213
211
  await handleRegistration(props.client, props.commands, props.devGuildIds, props.type);
214
212
  } else {
215
- throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`));
213
+ throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`));
216
214
  }
217
215
  } else {
218
216
  props.client.once("ready", async (c) => {
@@ -241,19 +239,20 @@ async function registerGlobalCommands(client, commands) {
241
239
  );
242
240
  if (command.options?.deleted) {
243
241
  if (!targetCommand) {
244
- console.log(
242
+ process.emitWarning(
245
243
  colors_default.yellow(
246
- `\u23E9 Ignoring: Command "${command.data.name}" is globally marked as deleted.`
244
+ `Ignoring: Command "${command.data.name}" is globally marked as deleted.`
247
245
  )
248
246
  );
249
247
  } else {
250
248
  await targetCommand.delete().catch((error) => {
251
- console.log(
252
- colors_default.red(`\u274C Failed to delete command "${command.data.name}" globally.`)
249
+ throw new Error(
250
+ colors_default.red(`Failed to delete command "${command.data.name}" globally.
251
+ `),
252
+ error
253
253
  );
254
- console.error(error);
255
254
  });
256
- console.log(colors_default.green(`\u{1F6AE} Deleted command "${command.data.name}" globally.`));
255
+ console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`));
257
256
  }
258
257
  continue;
259
258
  }
@@ -261,26 +260,26 @@ async function registerGlobalCommands(client, commands) {
261
260
  const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
262
261
  if (commandsAreDifferent) {
263
262
  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
- )
263
+ throw new Error(
264
+ colors_default.red(`Failed to edit command "${command.data.name}" globally.
265
+ `),
266
+ error
268
267
  );
269
- console.error(error);
270
268
  });
271
- console.log(colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`));
269
+ console.log(colors_default.green(`Edited command "${command.data.name}" globally.`));
272
270
  continue;
273
271
  }
274
272
  }
275
273
  if (targetCommand)
276
274
  continue;
277
275
  await appCommandsManager.create(command.data).catch((error) => {
278
- console.log(
279
- colors_default.red(`\u274C Failed to register command "${command.data.name}" globally.`)
276
+ throw new Error(
277
+ colors_default.red(`Failed to register command "${command.data.name}" globally.
278
+ `),
279
+ error
280
280
  );
281
- console.error(error);
282
281
  });
283
- console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
282
+ console.log(colors_default.green(`Registered command "${command.data.name}" globally.`));
284
283
  }
285
284
  }
286
285
  async function registerDevCommands(client, commands, guildIds) {
@@ -288,9 +287,9 @@ async function registerDevCommands(client, commands, guildIds) {
288
287
  for (const guildId of guildIds) {
289
288
  const guild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId);
290
289
  if (!guild) {
291
- console.log(
290
+ process.emitWarning(
292
291
  colors_default.yellow(
293
- `\u23E9 Ignoring: Guild ${guildId} does not exist or client isn't in this guild.`
292
+ `Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`
294
293
  )
295
294
  );
296
295
  continue;
@@ -308,23 +307,23 @@ async function registerDevCommands(client, commands, guildIds) {
308
307
  const targetCommand = guildCommands.cache.find((cmd) => cmd.name === command.data.name);
309
308
  if (command.options?.deleted) {
310
309
  if (!targetCommand) {
311
- console.log(
310
+ process.emitWarning(
312
311
  colors_default.yellow(
313
- `\u23E9 Ignoring: Command "${command.data.name}" is marked as deleted for ${guildCommands.guild.name}.`
312
+ `Ignoring: Command "${command.data.name}" is marked as deleted in ${guildCommands.guild.name}.`
314
313
  )
315
314
  );
316
315
  } else {
317
316
  await targetCommand.delete().catch((error) => {
318
- console.log(
317
+ throw new Error(
319
318
  colors_default.red(
320
- `\u274C Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
321
- )
319
+ `Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
320
+ ),
321
+ error
322
322
  );
323
- console.error(error);
324
323
  });
325
324
  console.log(
326
325
  colors_default.green(
327
- `\u{1F6AE} Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
326
+ `Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
328
327
  )
329
328
  );
330
329
  }
@@ -334,16 +333,17 @@ async function registerDevCommands(client, commands, guildIds) {
334
333
  const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
335
334
  if (commandsAreDifferent) {
336
335
  await targetCommand.edit(command.data).catch((error) => {
337
- console.log(
336
+ throw new Error(
338
337
  colors_default.red(
339
- `\u274C Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.`
340
- )
338
+ `Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.
339
+ `
340
+ ),
341
+ error
341
342
  );
342
- console.error(error);
343
343
  });
344
344
  console.log(
345
345
  colors_default.green(
346
- `\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
346
+ `Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
347
347
  )
348
348
  );
349
349
  continue;
@@ -352,16 +352,17 @@ async function registerDevCommands(client, commands, guildIds) {
352
352
  if (targetCommand)
353
353
  continue;
354
354
  await guildCommands.create(command.data).catch((error) => {
355
- console.log(
355
+ throw new Error(
356
356
  colors_default.red(
357
- `\u274C Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.`
358
- )
357
+ `Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.
358
+ `
359
+ ),
360
+ error
359
361
  );
360
- console.error(error);
361
362
  });
362
363
  console.log(
363
364
  colors_default.green(
364
- `\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
365
+ `Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
365
366
  )
366
367
  );
367
368
  }
@@ -483,16 +484,16 @@ var CommandHandler = class {
483
484
  this.#buildBuiltInValidations();
484
485
  const devOnlyCommands = this.#data.commands.filter((cmd) => cmd.options?.devOnly);
485
486
  if (devOnlyCommands.length && !this.#data.devGuildIds.length) {
486
- console.log(
487
+ process.emitWarning(
487
488
  colors_default.yellow(
488
- '\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devGuildIds" have not been set.'
489
+ 'You have commands marked as "devOnly", but "devGuildIds" have not been set.'
489
490
  )
490
491
  );
491
492
  }
492
493
  if (devOnlyCommands.length && !this.#data.devUserIds.length && !this.#data.devRoleIds.length) {
493
- console.log(
494
+ process.emitWarning(
494
495
  colors_default.yellow(
495
- '\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.'
496
+ 'You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.'
496
497
  )
497
498
  );
498
499
  }
@@ -531,33 +532,33 @@ var CommandHandler = class {
531
532
  commandObj.data = importedObj.data;
532
533
  }
533
534
  if (!commandObj.data) {
534
- console.log(
535
+ process.emitWarning(
535
536
  colors_default.yellow(
536
- `\u23E9 Ignoring: Command ${compactFilePath} does not export "data".`
537
+ `Ignoring: Command file ${compactFilePath} does not export "data".`
537
538
  )
538
539
  );
539
540
  continue;
540
541
  }
541
542
  if (!commandObj.data.name) {
542
- console.log(
543
+ process.emitWarning(
543
544
  colors_default.yellow(
544
- `\u23E9 Ignoring: Command ${compactFilePath} does not export "data.name".`
545
+ `Ignoring: Command file ${compactFilePath} does not export "data.name".`
545
546
  )
546
547
  );
547
548
  continue;
548
549
  }
549
550
  if (!commandObj.run) {
550
- console.log(
551
+ process.emitWarning(
551
552
  colors_default.yellow(
552
- `\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run".`
553
+ `Ignoring: Command file ${commandObj.data.name} does not export "run".`
553
554
  )
554
555
  );
555
556
  continue;
556
557
  }
557
558
  if (typeof commandObj.run !== "function") {
558
- console.log(
559
+ process.emitWarning(
559
560
  colors_default.yellow(
560
- `\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run" as a function.`
561
+ `Ignoring: Command file ${commandObj.data.name} does not export "run" as a function.`
561
562
  )
562
563
  );
563
564
  continue;
@@ -569,13 +570,6 @@ var CommandHandler = class {
569
570
  } else {
570
571
  commandObj.category = commandCategory;
571
572
  }
572
- if (commandObj.options?.guildOnly) {
573
- console.log(
574
- colors_default.yellow(
575
- `\u2139\uFE0F Deprecation warning: The command "${commandObj.data.name}" uses "options.guildOnly", which will be deprecated soon. Use "data.dm_permission" instead.`
576
- )
577
- );
578
- }
579
573
  this.#data.commands.push(commandObj);
580
574
  }
581
575
  }
@@ -649,7 +643,9 @@ var CommandHandler = class {
649
643
  async reloadCommands(type) {
650
644
  if (!this.#data.commandsPath) {
651
645
  throw new Error(
652
- 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
646
+ colors_default.red(
647
+ 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
648
+ )
653
649
  );
654
650
  }
655
651
  this.#data.commands = [];
@@ -711,9 +707,9 @@ var EventHandler = class {
711
707
  }
712
708
  const compactFilePath = eventFilePath.split(process.cwd())[1] || eventFilePath;
713
709
  if (typeof eventFunction !== "function") {
714
- console.log(
710
+ process.emitWarning(
715
711
  colors_default.yellow(
716
- `\u23E9 Ignoring: Event ${compactFilePath} does not export a function.`
712
+ `Ignoring: Event file ${compactFilePath} does not export a function.`
717
713
  )
718
714
  );
719
715
  continue;
@@ -742,7 +738,9 @@ var EventHandler = class {
742
738
  async reloadEvents(commandHandler) {
743
739
  if (!this.#data.eventsPath) {
744
740
  throw new Error(
745
- 'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
741
+ colors_default.red(
742
+ 'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
743
+ )
746
744
  );
747
745
  }
748
746
  this.#data.events = [];
@@ -782,9 +780,9 @@ var ValidationHandler = class {
782
780
  }
783
781
  const compactFilePath = validationFilePath.split(process.cwd())[1] || validationFilePath;
784
782
  if (typeof validationFunction !== "function") {
785
- console.log(
783
+ process.emitWarning(
786
784
  colors_default.yellow(
787
- `\u23E9 Ignoring: Validation ${compactFilePath} does not export a function.`
785
+ `Ignoring: Validation file ${compactFilePath} does not export a function.`
788
786
  )
789
787
  );
790
788
  continue;
@@ -799,7 +797,9 @@ var ValidationHandler = class {
799
797
  async reloadValidations() {
800
798
  if (!this.#data.validationsPath) {
801
799
  throw new Error(
802
- 'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
800
+ colors_default.red(
801
+ 'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
802
+ )
803
803
  );
804
804
  }
805
805
  const newValidations = await this.#buildValidations();
package/dist/index.mjs CHANGED
@@ -93,7 +93,7 @@ async function loadCommandsWithRest(props) {
93
93
  props.type
94
94
  );
95
95
  } else {
96
- throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`));
96
+ throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`));
97
97
  }
98
98
  } else {
99
99
  props.client.once("ready", async (c) => {
@@ -117,18 +117,16 @@ async function handleLoading(client, commands, devGuildIds, reloading, type) {
117
117
  async function loadGlobalCommands(client, commands, reloading) {
118
118
  const requestBody = commands.map((cmd) => cmd.data);
119
119
  await client.application.commands.set(requestBody).catch((error) => {
120
- console.log(
120
+ throw new Error(
121
121
  colors_default.red(
122
- `\u274C Error ${reloading ? "reloading" : "loading"} global application commands.
122
+ `Error ${reloading ? "reloading" : "loading"} global application commands.
123
123
  `
124
- )
124
+ ),
125
+ error
125
126
  );
126
- throw new Error(error);
127
127
  });
128
128
  console.log(
129
- colors_default.green(
130
- `\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`
131
- )
129
+ colors_default.green(`${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} global commands.`)
132
130
  );
133
131
  }
134
132
  async function loadDevCommands(client, commands, guildIds, reloading) {
@@ -136,23 +134,23 @@ async function loadDevCommands(client, commands, guildIds, reloading) {
136
134
  for (const guildId of guildIds) {
137
135
  const targetGuild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId);
138
136
  if (!targetGuild) {
139
- console.log(
140
- `Couldn't ${reloading ? "reloading" : "loading"} commands in guild "${targetGuild}" - guild doesn't exist or client isn't part of the guild.`
137
+ process.emitWarning(
138
+ `Cannot ${reloading ? "reload" : "load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.`
141
139
  );
142
140
  continue;
143
141
  }
144
142
  await targetGuild.commands.set(requestBody).catch((error) => {
145
- console.log(
143
+ throw new Error(
146
144
  colors_default.red(
147
- `\u274C Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}".
145
+ `Error ${reloading ? "reloading" : "loading"} developer application commands in guild "${targetGuild?.name || guildId}".
148
146
  `
149
- )
147
+ ),
148
+ error
150
149
  );
151
- throw new Error(error);
152
150
  });
153
151
  console.log(
154
152
  colors_default.green(
155
- `\u2705 ${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`
153
+ `${reloading ? "Reloaded" : "Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`
156
154
  )
157
155
  );
158
156
  }
@@ -179,7 +177,7 @@ async function registerCommands(props) {
179
177
  if (props.client.isReady()) {
180
178
  await handleRegistration(props.client, props.commands, props.devGuildIds, props.type);
181
179
  } else {
182
- throw new Error(colors_default.red(`\u274C Cannot reload commands when client is not ready.`));
180
+ throw new Error(colors_default.red(`Cannot reload commands when client is not ready.`));
183
181
  }
184
182
  } else {
185
183
  props.client.once("ready", async (c) => {
@@ -208,19 +206,20 @@ async function registerGlobalCommands(client, commands) {
208
206
  );
209
207
  if (command.options?.deleted) {
210
208
  if (!targetCommand) {
211
- console.log(
209
+ process.emitWarning(
212
210
  colors_default.yellow(
213
- `\u23E9 Ignoring: Command "${command.data.name}" is globally marked as deleted.`
211
+ `Ignoring: Command "${command.data.name}" is globally marked as deleted.`
214
212
  )
215
213
  );
216
214
  } else {
217
215
  await targetCommand.delete().catch((error) => {
218
- console.log(
219
- colors_default.red(`\u274C Failed to delete command "${command.data.name}" globally.`)
216
+ throw new Error(
217
+ colors_default.red(`Failed to delete command "${command.data.name}" globally.
218
+ `),
219
+ error
220
220
  );
221
- console.error(error);
222
221
  });
223
- console.log(colors_default.green(`\u{1F6AE} Deleted command "${command.data.name}" globally.`));
222
+ console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`));
224
223
  }
225
224
  continue;
226
225
  }
@@ -228,26 +227,26 @@ async function registerGlobalCommands(client, commands) {
228
227
  const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
229
228
  if (commandsAreDifferent) {
230
229
  await targetCommand.edit(command.data).catch((error) => {
231
- console.log(
232
- colors_default.red(
233
- `\u274C Failed to edit command "${command.data.name}" globally.`
234
- )
230
+ throw new Error(
231
+ colors_default.red(`Failed to edit command "${command.data.name}" globally.
232
+ `),
233
+ error
235
234
  );
236
- console.error(error);
237
235
  });
238
- console.log(colors_default.green(`\u2705 Edited command "${command.data.name}" globally.`));
236
+ console.log(colors_default.green(`Edited command "${command.data.name}" globally.`));
239
237
  continue;
240
238
  }
241
239
  }
242
240
  if (targetCommand)
243
241
  continue;
244
242
  await appCommandsManager.create(command.data).catch((error) => {
245
- console.log(
246
- colors_default.red(`\u274C Failed to register command "${command.data.name}" globally.`)
243
+ throw new Error(
244
+ colors_default.red(`Failed to register command "${command.data.name}" globally.
245
+ `),
246
+ error
247
247
  );
248
- console.error(error);
249
248
  });
250
- console.log(colors_default.green(`\u2705 Registered command "${command.data.name}" globally.`));
249
+ console.log(colors_default.green(`Registered command "${command.data.name}" globally.`));
251
250
  }
252
251
  }
253
252
  async function registerDevCommands(client, commands, guildIds) {
@@ -255,9 +254,9 @@ async function registerDevCommands(client, commands, guildIds) {
255
254
  for (const guildId of guildIds) {
256
255
  const guild = client.guilds.cache.get(guildId) || await client.guilds.fetch(guildId);
257
256
  if (!guild) {
258
- console.log(
257
+ process.emitWarning(
259
258
  colors_default.yellow(
260
- `\u23E9 Ignoring: Guild ${guildId} does not exist or client isn't in this guild.`
259
+ `Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`
261
260
  )
262
261
  );
263
262
  continue;
@@ -275,23 +274,23 @@ async function registerDevCommands(client, commands, guildIds) {
275
274
  const targetCommand = guildCommands.cache.find((cmd) => cmd.name === command.data.name);
276
275
  if (command.options?.deleted) {
277
276
  if (!targetCommand) {
278
- console.log(
277
+ process.emitWarning(
279
278
  colors_default.yellow(
280
- `\u23E9 Ignoring: Command "${command.data.name}" is marked as deleted for ${guildCommands.guild.name}.`
279
+ `Ignoring: Command "${command.data.name}" is marked as deleted in ${guildCommands.guild.name}.`
281
280
  )
282
281
  );
283
282
  } else {
284
283
  await targetCommand.delete().catch((error) => {
285
- console.log(
284
+ throw new Error(
286
285
  colors_default.red(
287
- `\u274C Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
288
- )
286
+ `Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`
287
+ ),
288
+ error
289
289
  );
290
- console.error(error);
291
290
  });
292
291
  console.log(
293
292
  colors_default.green(
294
- `\u{1F6AE} Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
293
+ `Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`
295
294
  )
296
295
  );
297
296
  }
@@ -301,16 +300,17 @@ async function registerDevCommands(client, commands, guildIds) {
301
300
  const commandsAreDifferent = areSlashCommandsDifferent(targetCommand, command.data);
302
301
  if (commandsAreDifferent) {
303
302
  await targetCommand.edit(command.data).catch((error) => {
304
- console.log(
303
+ throw new Error(
305
304
  colors_default.red(
306
- `\u274C Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.`
307
- )
305
+ `Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.
306
+ `
307
+ ),
308
+ error
308
309
  );
309
- console.error(error);
310
310
  });
311
311
  console.log(
312
312
  colors_default.green(
313
- `\u2705 Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
313
+ `Edited command "${command.data.name}" in ${guildCommands.guild.name}.`
314
314
  )
315
315
  );
316
316
  continue;
@@ -319,16 +319,17 @@ async function registerDevCommands(client, commands, guildIds) {
319
319
  if (targetCommand)
320
320
  continue;
321
321
  await guildCommands.create(command.data).catch((error) => {
322
- console.log(
322
+ throw new Error(
323
323
  colors_default.red(
324
- `\u274C Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.`
325
- )
324
+ `Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.
325
+ `
326
+ ),
327
+ error
326
328
  );
327
- console.error(error);
328
329
  });
329
330
  console.log(
330
331
  colors_default.green(
331
- `\u2705 Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
332
+ `Registered command "${command.data.name}" in ${guildCommands.guild.name}.`
332
333
  )
333
334
  );
334
335
  }
@@ -450,16 +451,16 @@ var CommandHandler = class {
450
451
  this.#buildBuiltInValidations();
451
452
  const devOnlyCommands = this.#data.commands.filter((cmd) => cmd.options?.devOnly);
452
453
  if (devOnlyCommands.length && !this.#data.devGuildIds.length) {
453
- console.log(
454
+ process.emitWarning(
454
455
  colors_default.yellow(
455
- '\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devGuildIds" have not been set.'
456
+ 'You have commands marked as "devOnly", but "devGuildIds" have not been set.'
456
457
  )
457
458
  );
458
459
  }
459
460
  if (devOnlyCommands.length && !this.#data.devUserIds.length && !this.#data.devRoleIds.length) {
460
- console.log(
461
+ process.emitWarning(
461
462
  colors_default.yellow(
462
- '\u2139\uFE0F Warning: You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.'
463
+ 'You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.'
463
464
  )
464
465
  );
465
466
  }
@@ -498,33 +499,33 @@ var CommandHandler = class {
498
499
  commandObj.data = importedObj.data;
499
500
  }
500
501
  if (!commandObj.data) {
501
- console.log(
502
+ process.emitWarning(
502
503
  colors_default.yellow(
503
- `\u23E9 Ignoring: Command ${compactFilePath} does not export "data".`
504
+ `Ignoring: Command file ${compactFilePath} does not export "data".`
504
505
  )
505
506
  );
506
507
  continue;
507
508
  }
508
509
  if (!commandObj.data.name) {
509
- console.log(
510
+ process.emitWarning(
510
511
  colors_default.yellow(
511
- `\u23E9 Ignoring: Command ${compactFilePath} does not export "data.name".`
512
+ `Ignoring: Command file ${compactFilePath} does not export "data.name".`
512
513
  )
513
514
  );
514
515
  continue;
515
516
  }
516
517
  if (!commandObj.run) {
517
- console.log(
518
+ process.emitWarning(
518
519
  colors_default.yellow(
519
- `\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run".`
520
+ `Ignoring: Command file ${commandObj.data.name} does not export "run".`
520
521
  )
521
522
  );
522
523
  continue;
523
524
  }
524
525
  if (typeof commandObj.run !== "function") {
525
- console.log(
526
+ process.emitWarning(
526
527
  colors_default.yellow(
527
- `\u23E9 Ignoring: Command ${commandObj.data.name} does not export "run" as a function.`
528
+ `Ignoring: Command file ${commandObj.data.name} does not export "run" as a function.`
528
529
  )
529
530
  );
530
531
  continue;
@@ -536,13 +537,6 @@ var CommandHandler = class {
536
537
  } else {
537
538
  commandObj.category = commandCategory;
538
539
  }
539
- if (commandObj.options?.guildOnly) {
540
- console.log(
541
- colors_default.yellow(
542
- `\u2139\uFE0F Deprecation warning: The command "${commandObj.data.name}" uses "options.guildOnly", which will be deprecated soon. Use "data.dm_permission" instead.`
543
- )
544
- );
545
- }
546
540
  this.#data.commands.push(commandObj);
547
541
  }
548
542
  }
@@ -616,7 +610,9 @@ var CommandHandler = class {
616
610
  async reloadCommands(type) {
617
611
  if (!this.#data.commandsPath) {
618
612
  throw new Error(
619
- 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
613
+ colors_default.red(
614
+ 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
615
+ )
620
616
  );
621
617
  }
622
618
  this.#data.commands = [];
@@ -678,9 +674,9 @@ var EventHandler = class {
678
674
  }
679
675
  const compactFilePath = eventFilePath.split(process.cwd())[1] || eventFilePath;
680
676
  if (typeof eventFunction !== "function") {
681
- console.log(
677
+ process.emitWarning(
682
678
  colors_default.yellow(
683
- `\u23E9 Ignoring: Event ${compactFilePath} does not export a function.`
679
+ `Ignoring: Event file ${compactFilePath} does not export a function.`
684
680
  )
685
681
  );
686
682
  continue;
@@ -709,7 +705,9 @@ var EventHandler = class {
709
705
  async reloadEvents(commandHandler) {
710
706
  if (!this.#data.eventsPath) {
711
707
  throw new Error(
712
- 'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
708
+ colors_default.red(
709
+ 'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
710
+ )
713
711
  );
714
712
  }
715
713
  this.#data.events = [];
@@ -749,9 +747,9 @@ var ValidationHandler = class {
749
747
  }
750
748
  const compactFilePath = validationFilePath.split(process.cwd())[1] || validationFilePath;
751
749
  if (typeof validationFunction !== "function") {
752
- console.log(
750
+ process.emitWarning(
753
751
  colors_default.yellow(
754
- `\u23E9 Ignoring: Validation ${compactFilePath} does not export a function.`
752
+ `Ignoring: Validation file ${compactFilePath} does not export a function.`
755
753
  )
756
754
  );
757
755
  continue;
@@ -766,7 +764,9 @@ var ValidationHandler = class {
766
764
  async reloadValidations() {
767
765
  if (!this.#data.validationsPath) {
768
766
  throw new Error(
769
- 'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
767
+ colors_default.red(
768
+ 'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
769
+ )
770
770
  );
771
771
  }
772
772
  const newValidations = await this.#buildValidations();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "commandkit",
3
3
  "description": "Beginner friendly command & event handler for Discord.js",
4
- "version": "0.1.10-dev.20231214182432",
4
+ "version": "0.1.10-dev.20231229094034",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",