seedcord 0.16.0-next.0 → 0.16.0-next.2

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
@@ -533,7 +533,7 @@ function Middleware(type, priority = 0, options = {}) {
533
533
  const metadata = {
534
534
  priority: normalizedPriority,
535
535
  type,
536
- ...options.events && options.events.length > 0 ? { events: options.events } : {}
536
+ ...options.events && options.events.length > 0 && { events: options.events }
537
537
  };
538
538
  Reflect.defineMetadata(MiddlewareMetadataKey, metadata, ctor);
539
539
  };
@@ -1081,7 +1081,7 @@ function checkPermissions(a, b, c, d, e) {
1081
1081
  in: b,
1082
1082
  scope: c,
1083
1083
  inverse: d ?? false,
1084
- ...e ?? {}
1084
+ ...e
1085
1085
  } : a;
1086
1086
  const Missing = missingCtor ?? MissingPermissions;
1087
1087
  const Dangerous = dangerousCtor ?? HasDangerousPermissions;
@@ -1348,7 +1348,7 @@ var CommandMentionInjector = class {
1348
1348
  return (0, discord_js.chatInputApplicationCommandMention)(name ?? route, id);
1349
1349
  }
1350
1350
  toPlain(route) {
1351
- return `/${route.split("/").join(" ")}`;
1351
+ return `/${route.replaceAll("/", " ")}`;
1352
1352
  }
1353
1353
  clear() {
1354
1354
  for (const key of Object.keys(mentionStorage)) Reflect.deleteProperty(mentionStorage, key);
@@ -1489,7 +1489,7 @@ async function fetchRoleInGuild(guild, roleId) {
1489
1489
  }
1490
1490
  }
1491
1491
  async function scanGuildsForRole(client, roleId) {
1492
- const cached = client.guilds.cache.map((guild) => guild.roles.cache.get(roleId)).find((role) => role);
1492
+ const cached = client.guilds.cache.map((guild) => guild.roles.cache.get(roleId)).find(Boolean);
1493
1493
  if (cached) return cached;
1494
1494
  for (const guild of client.guilds.cache.values()) try {
1495
1495
  const role = await guild.roles.fetch(roleId);
@@ -2453,7 +2453,7 @@ var Controls = class {
2453
2453
  };
2454
2454
  }
2455
2455
  row(...keys) {
2456
- if (keys.length < 1) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationEmptyControls);
2456
+ if (keys.length === 0) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationEmptyControls);
2457
2457
  if (keys.length > MAX_BUTTONS_PER_ROW) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationTooManyControls, [keys.length]);
2458
2458
  const seen = /* @__PURE__ */ new Set();
2459
2459
  for (const key of keys) {
@@ -2517,7 +2517,7 @@ const CURSOR_KEYS = [
2517
2517
  function renderPage(view, cursor, config) {
2518
2518
  const controls = new Controls(cursor, view);
2519
2519
  if (config.render) return toReplyResponse(config.render(view, controls));
2520
- return { components: [new PageContainer(view, config.renderItem ?? ((item) => String(item)), controls.row(...view.totalPages === void 0 ? CURSOR_KEYS : ARRAY_KEYS)).component] };
2520
+ return { components: [new PageContainer(view, config.renderItem ?? String, controls.row(...view.totalPages === void 0 ? CURSOR_KEYS : ARRAY_KEYS)).component] };
2521
2521
  }
2522
2522
 
2523
2523
  //#endregion
@@ -2594,7 +2594,7 @@ var ArraySource = class {
2594
2594
  constructor(load, opts) {
2595
2595
  this.load = load;
2596
2596
  this.perPage = opts?.perPage ?? DEFAULT_PER_PAGE;
2597
- if (!Number.isInteger(this.perPage) || this.perPage <= 0) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationInvalidPerPage, [this.perPage]);
2597
+ if (!Number.isSafeInteger(this.perPage) || this.perPage <= 0) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationInvalidPerPage, [this.perPage]);
2598
2598
  }
2599
2599
  async page(ctx, n) {
2600
2600
  return (0, _seedcord_kit.paginate)(await this.load(ctx), n, this.perPage);
@@ -2614,7 +2614,7 @@ var CursorSource = class {
2614
2614
  constructor(fetch, opts) {
2615
2615
  this.fetch = fetch;
2616
2616
  this.perPage = opts?.perPage ?? DEFAULT_PER_PAGE;
2617
- if (!Number.isInteger(this.perPage) || this.perPage <= 0) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationInvalidPerPage, [this.perPage]);
2617
+ if (!Number.isSafeInteger(this.perPage) || this.perPage <= 0) throw new _seedcord_errors_internal.SeedcordRangeError(_seedcord_errors.SeedcordErrorCode.PaginationInvalidPerPage, [this.perPage]);
2618
2618
  }
2619
2619
  async page(ctx, n) {
2620
2620
  const page = Math.max(0, Math.trunc(n));
@@ -2742,7 +2742,6 @@ var HmrModuleHandler = class {
2742
2742
  async handle(event) {
2743
2743
  const { file, affectedModules, type } = event;
2744
2744
  const { logger, handlersDir, middlewaresDir } = this.options;
2745
- const rollbackEnabled = event.rollback ?? true;
2746
2745
  if (type === "delete" || type === "deleteDir") {
2747
2746
  this.unload(file);
2748
2747
  return;
@@ -2754,6 +2753,7 @@ var HmrModuleHandler = class {
2754
2753
  }
2755
2754
  return;
2756
2755
  }
2756
+ const rollbackEnabled = event.rollback ?? true;
2757
2757
  const filesToReload = affectedModules && affectedModules.length > 0 ? affectedModules : [file];
2758
2758
  const absHandlersDir = (0, node_path.resolve)(process.cwd(), handlersDir);
2759
2759
  const absMiddlewaresDir = middlewaresDir ? (0, node_path.resolve)(process.cwd(), middlewaresDir) : null;
@@ -2859,8 +2859,8 @@ var HmrModuleHandler = class {
2859
2859
  }
2860
2860
  snapshotUnits(file) {
2861
2861
  return {
2862
- handlers: Array.from(this.store.fileToHandlers.get(file) ?? []),
2863
- middlewares: Array.from(this.store.fileToMiddlewares.get(file) ?? [])
2862
+ handlers: [...this.store.fileToHandlers.get(file) ?? []],
2863
+ middlewares: [...this.store.fileToMiddlewares.get(file) ?? []]
2864
2864
  };
2865
2865
  }
2866
2866
  restoreUnits(file, snapshot) {
@@ -2989,7 +2989,7 @@ var CommandRegistry = class {
2989
2989
  if (commandsDir && event.file.startsWith((0, node_path.resolve)(process.cwd(), commandsDir))) {
2990
2990
  this.pendingEvents.delete(event.file);
2991
2991
  this.pendingEvents.set(event.file, event);
2992
- getDevChannel()?.send("seedcord:commands-update-prompt", { files: Array.from(this.pendingEvents.keys()).map((f) => (0, _seedcord_utils.formatFilePath)(f)) });
2992
+ getDevChannel()?.send("seedcord:commands-update-prompt", { files: [...this.pendingEvents.keys()].map((f) => (0, _seedcord_utils.formatFilePath)(f)) });
2993
2993
  } else await this.hmrHandler?.handle(event);
2994
2994
  }
2995
2995
  async loadCommands(dir) {
@@ -3025,7 +3025,7 @@ var CommandRegistry = class {
3025
3025
  this.ctorToCommand.set(ctor, {
3026
3026
  name: comp.name,
3027
3027
  scope: meta.scope,
3028
- ...meta.scope === "guild" ? { guilds: meta.guilds } : {}
3028
+ ...meta.scope === "guild" && { guilds: meta.guilds }
3029
3029
  });
3030
3030
  }
3031
3031
  unregisterCommand(ctor, artifacts) {
@@ -3269,7 +3269,7 @@ function handleEventFault(caught, eventName, handlerName, args, core) {
3269
3269
  if (caught.reason !== void 0) logger$1.debug(`Silence: ${caught.reason}`);
3270
3270
  return;
3271
3271
  }
3272
- if (!(caught instanceof Error)) throw caught;
3272
+ if (!Error.isError(caught)) throw caught;
3273
3273
  const ignore = new Set(core.config.errors?.ignoreEventApiCodes ?? []);
3274
3274
  if (caught instanceof discord_js.DiscordAPIError && ignore.has(caught.code)) {
3275
3275
  logger$1.debug(`swallowed api code ${caught.code}`);
@@ -3315,7 +3315,7 @@ var EventDispatcher = class {
3315
3315
  if (!envapt.Envapter.isDevelopment && !envapt.Envapter.isTest) return;
3316
3316
  this.hmrHandler = new HmrModuleHandler({
3317
3317
  handlersDir: eventsDir,
3318
- ...(0, _seedcord_utils.hasKeys)(this.core.config.bot.events, ["middlewares"]) ? { middlewaresDir: this.core.config.bot.events.middlewares } : {},
3318
+ ...(0, _seedcord_utils.hasKeys)(this.core.config.bot.events, ["middlewares"]) && { middlewaresDir: this.core.config.bot.events.middlewares },
3319
3319
  isHandler: this.isEventHandlerClass.bind(this),
3320
3320
  isMiddleware: this.isMiddlewareClass.bind(this),
3321
3321
  registerHandler: this.registerHandler.bind(this),
@@ -3374,7 +3374,7 @@ var EventDispatcher = class {
3374
3374
  await this.hmrHandler?.handle(event);
3375
3375
  }
3376
3376
  unregisterHandler(handlerClass, artifacts) {
3377
- const events = artifacts ?? Array.from(this.eventMap.keys());
3377
+ const events = artifacts ?? [...this.eventMap.keys()];
3378
3378
  for (const event of events) {
3379
3379
  const handlers = this.eventMap.get(event);
3380
3380
  if (!handlers) continue;
@@ -3396,7 +3396,7 @@ var EventDispatcher = class {
3396
3396
  this.middlewares.push({
3397
3397
  ctor: middlewareCtor,
3398
3398
  priority: metadata.priority,
3399
- ...metadata.events ? { events: metadata.events } : {}
3399
+ ...metadata.events && { events: metadata.events }
3400
3400
  });
3401
3401
  this.middlewares.sort((a, b) => a.priority - b.priority);
3402
3402
  this.logger.utils.registration(`${middlewareCtor.name} ${chalk.default.gray(`(${metadata.priority})`)}`, relativePath, "event middleware");
@@ -3518,7 +3518,7 @@ async function handleInteractionFault(caught, interaction, core) {
3518
3518
  if (caught.reason !== void 0) logger.debug(`Silence: ${caught.reason}`);
3519
3519
  return;
3520
3520
  }
3521
- if (!(caught instanceof Error)) throw caught;
3521
+ if (!Error.isError(caught)) throw caught;
3522
3522
  const ignore = new Set(core.config.errors?.ignoreApiCodes ?? []);
3523
3523
  if (caught instanceof discord_js.DiscordAPIError && ignore.has(caught.code)) {
3524
3524
  logger.debug(`swallowed api code ${caught.code}`);
@@ -3592,7 +3592,7 @@ var InteractionDispatcher = class {
3592
3592
  if (!envapt.Envapter.isDevelopment && !envapt.Envapter.isTest) return;
3593
3593
  this.hmrHandler = new HmrModuleHandler({
3594
3594
  handlersDir: interactionsDir,
3595
- ...(0, _seedcord_utils.hasKeys)(this.core.config.bot.interactions, ["middlewares"]) && this.core.config.bot.interactions.middlewares ? { middlewaresDir: this.core.config.bot.interactions.middlewares } : {},
3595
+ ...(0, _seedcord_utils.hasKeys)(this.core.config.bot.interactions, ["middlewares"]) && this.core.config.bot.interactions.middlewares && { middlewaresDir: this.core.config.bot.interactions.middlewares },
3596
3596
  isHandler: this.isHandlerClass.bind(this),
3597
3597
  isMiddleware: this.isMiddlewareClass.bind(this),
3598
3598
  registerHandler: this.registerHandler.bind(this),
@@ -3988,7 +3988,7 @@ var HmrManager = class {
3988
3988
  this.listeners.delete(listener);
3989
3989
  }
3990
3990
  async handleUpdate(event) {
3991
- const promises = Array.from(this.listeners).map(async (listener) => {
3991
+ const promises = [...this.listeners].map(async (listener) => {
3992
3992
  try {
3993
3993
  await listener.onHmr(event);
3994
3994
  } catch (error) {
@@ -4017,7 +4017,7 @@ function isDiscordWebhookUrl(value) {
4017
4017
  */
4018
4018
  function jsonAttachment(name, description, data) {
4019
4019
  const content = (0, _seedcord_utils.filterCirculars)(data);
4020
- return new discord_js.AttachmentBuilder(Buffer.from(JSON.stringify(content, void 0, 2), "utf-8"), {
4020
+ return new discord_js.AttachmentBuilder(Buffer.from(JSON.stringify(content, void 0, 2), "utf8"), {
4021
4021
  name,
4022
4022
  description
4023
4023
  });
@@ -4092,7 +4092,7 @@ function faultSummary(denial, source) {
4092
4092
  */
4093
4093
  function causeStack(denial) {
4094
4094
  const { cause } = denial;
4095
- if (cause instanceof Error) return cause.stack ?? cause.message;
4095
+ if (Error.isError(cause)) return cause.stack ?? cause.message;
4096
4096
  if (typeof cause === "string") return cause;
4097
4097
  if (typeof cause === "bigint" || typeof cause === "symbol" || typeof cause === "function") return cause.toString();
4098
4098
  if (cause !== void 0) try {
@@ -4209,7 +4209,7 @@ var Bus = class extends Plugin {
4209
4209
  if (subscribersDir) {
4210
4210
  this.logger.info(chalk.default.bold(subscribersDir));
4211
4211
  await this.loadSubscribers(subscribersDir);
4212
- const totalSubscribers = Array.from(this.subscribersMap.values()).reduce((acc, handlers) => acc + handlers.length, 0);
4212
+ const totalSubscribers = [...this.subscribersMap.values()].reduce((acc, handlers) => acc + handlers.length, 0);
4213
4213
  this.logger.utils.list([`${chalk.default.bold.magenta(totalSubscribers)} subscribers`], chalk.default.bold.green("Loaded"));
4214
4214
  }
4215
4215
  }
@@ -4242,7 +4242,7 @@ var Bus = class extends Plugin {
4242
4242
  });
4243
4243
  }
4244
4244
  unregisterSubscriber(handler, artifacts) {
4245
- const subscribers = artifacts ?? Array.from(this.subscribersMap.keys());
4245
+ const subscribers = artifacts ?? [...this.subscribersMap.keys()];
4246
4246
  for (const subscriber of subscribers) {
4247
4247
  const handlers = this.subscribersMap.get(subscriber);
4248
4248
  if (!handlers) continue;
@@ -4392,7 +4392,7 @@ var Seedcord = class Seedcord extends Pluggable {
4392
4392
  //#endregion
4393
4393
  //#region src/index.ts
4394
4394
  /** Package version */
4395
- const version = "0.16.0-next.0";
4395
+ const version = "0.16.0-next.2";
4396
4396
 
4397
4397
  //#endregion
4398
4398
  exports.ArraySource = ArraySource;