vimcord 1.0.48 → 1.0.50

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.cjs CHANGED
@@ -316,6 +316,7 @@ var BaseCommandBuilder = class {
316
316
  async run(client, ...args) {
317
317
  const config = this.resolveConfig(client);
318
318
  const ctx = this.extractContext(args);
319
+ let cancel = false;
319
320
  try {
320
321
  if (!config.enabled) {
321
322
  return await config.onUsedWhenDisabled?.(...args);
@@ -330,7 +331,8 @@ var BaseCommandBuilder = class {
330
331
  if (!await this.checkConditions(config, ...args)) {
331
332
  return await config.onConditionsNotMet?.(...args);
332
333
  }
333
- await config.beforeExecute?.(...args);
334
+ await config.beforeExecute?.({ cancel: () => cancel = true }, ...args);
335
+ if (cancel) return;
334
336
  if (config.logExecution !== false) {
335
337
  const cmdName = this.options.name || this.builder?.name || "Unknown";
336
338
  const location = ctx.guild ? `${ctx.guild.name} (${ctx.guild.id})` : "Direct Messages";
@@ -1787,7 +1789,7 @@ var VimcordErrorHandler = class {
1787
1789
  var import_chalk2 = __toESM(require("chalk"));
1788
1790
 
1789
1791
  // package.json
1790
- var version = "1.0.48";
1792
+ var version = "1.0.50";
1791
1793
 
1792
1794
  // src/client/vimcord.logger.ts
1793
1795
  var clientLoggerFactory = (client) => new Logger({ prefixEmoji: "\u26A1", prefix: `vimcord (i${client.clientId})` }).extend({
@@ -3072,7 +3074,6 @@ var MongoDatabase = class _MongoDatabase {
3072
3074
 
3073
3075
  // src/db/mongo/mongoSchema.builder.ts
3074
3076
  var import_mongoose2 = require("mongoose");
3075
- var import_node_crypto4 = require("crypto");
3076
3077
  var import_qznt6 = require("qznt");
3077
3078
  try {
3078
3079
  import("mongoose");
@@ -3179,16 +3180,15 @@ var MongoSchemaBuilder = class _MongoSchemaBuilder {
3179
3180
  return await this.db.useTransaction((session) => fn(session, model));
3180
3181
  });
3181
3182
  }
3182
- async createHexId(bytes, path2, maxRetries = 10) {
3183
+ async createUniqueId(collisionPath, fn, maxRetries = 10) {
3183
3184
  return this.execute(async (model) => {
3184
- const createHex = () => (0, import_node_crypto4.randomBytes)(bytes).toString("hex");
3185
- let id = createHex();
3185
+ let id;
3186
3186
  let tries = 0;
3187
- while (await model.exists({ [path2]: id })) {
3188
- if (tries >= maxRetries) throw Error(`Failed to generate a unique hex ID after ${tries} attempt(s)`);
3189
- id = createHex();
3187
+ do {
3188
+ if (tries >= maxRetries) throw new Error(`Failed to generate a unique ID after ${tries} attempt(s)`);
3189
+ id = fn();
3190
3190
  tries++;
3191
- }
3191
+ } while (await model.exists({ [collisionPath]: id }));
3192
3192
  return id;
3193
3193
  });
3194
3194
  }