vimcord 1.0.23 → 1.0.24

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
@@ -31,16 +31,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  BaseCommandBuilder: () => BaseCommandBuilder,
34
+ BaseCommandManager: () => BaseCommandManager,
34
35
  BetterCollector: () => BetterCollector,
35
36
  BetterContainer: () => BetterContainer,
36
37
  BetterEmbed: () => BetterEmbed,
37
38
  BetterModal: () => BetterModal,
38
39
  CLI: () => CLI,
39
40
  CollectorTimeoutType: () => CollectorTimeoutType,
41
+ CommandManager: () => CommandManager,
40
42
  CommandType: () => CommandType,
41
43
  ContextCommandBuilder: () => ContextCommandBuilder,
44
+ ContextCommandManager: () => ContextCommandManager,
42
45
  DynaSend: () => DynaSend,
43
46
  EventBuilder: () => EventBuilder,
47
+ EventManager: () => EventManager,
44
48
  LOGGER_COLORS: () => LOGGER_COLORS,
45
49
  LogLevel: () => LogLevel,
46
50
  Logger: () => Logger,
@@ -51,20 +55,17 @@ __export(index_exports, {
51
55
  PaginationType: () => PaginationType,
52
56
  Paginator: () => Paginator,
53
57
  PrefixCommandBuilder: () => PrefixCommandBuilder,
58
+ PrefixCommandManager: () => PrefixCommandManager,
54
59
  Prompt: () => Prompt,
55
60
  PromptResolveType: () => PromptResolveType,
56
61
  RateLimitScope: () => RateLimitScope,
57
62
  SendMethod: () => SendMethod,
58
63
  SlashCommandBuilder: () => SlashCommandBuilder,
64
+ SlashCommandManager: () => SlashCommandManager,
65
+ StatusManager: () => StatusManager,
59
66
  StatusType: () => StatusType,
60
67
  Vimcord: () => Vimcord,
61
68
  VimcordCLI: () => VimcordCLI,
62
- VimcordCommandManager: () => VimcordCommandManager,
63
- VimcordContextCommandManager: () => VimcordContextCommandManager,
64
- VimcordEventManager: () => VimcordEventManager,
65
- VimcordPrefixCommandManager: () => VimcordPrefixCommandManager,
66
- VimcordSlashCommandManager: () => VimcordSlashCommandManager,
67
- VimcordStatusManager: () => VimcordStatusManager,
68
69
  __zero: () => __zero,
69
70
  cleanMention: () => cleanMention,
70
71
  clientInstances: () => clientInstances,
@@ -196,18 +197,8 @@ function validateCommandPermissions(permissions, client, user, command) {
196
197
  return { validated: false, failReason: 7 /* NotBotOwner */ };
197
198
  }
198
199
  if (__existsAndTrue(permissions.botStaffOnly)) {
199
- if (!client.config.staff.superUsers.includes(user.id)) {
200
- return { validated: false, failReason: 8 /* NotBotStaff */ };
201
- }
202
- if (inGuild) {
203
- for (const [k, role] of user.roles.cache) {
204
- if (!user.roles.cache.has(role.id)) {
205
- missingRoles.push(role.id);
206
- }
207
- }
208
- if (missingRoles.length) {
209
- return { validated: false, failReason: 8 /* NotBotStaff */, missingRoles };
210
- }
200
+ if (client.config.staff.ownerId === user.id || client.config.staff.superUsers.includes(user.id)) {
201
+ return { validated: true };
211
202
  }
212
203
  if (command instanceof import_discord.BaseInteraction && command.isCommand()) {
213
204
  let commandName = null;
@@ -217,17 +208,30 @@ function validateCommandPermissions(permissions, client, user, command) {
217
208
  } else {
218
209
  commandName = command.commandName;
219
210
  }
220
- if (!client.config.staff.bypassers.some(
211
+ if (client.config.staff.bypassers.some(
221
212
  (bypass) => bypass.commandName.toLowerCase() === commandName.toLowerCase() && bypass.userIds.includes(user.id)
222
213
  )) {
223
- return { validated: false, failReason: 8 /* NotBotStaff */ };
214
+ return { validated: true };
224
215
  }
225
216
  }
226
- if (typeof command === "string" && !client.config.staff.bypassers.some(
217
+ if (typeof command === "string" && client.config.staff.bypassers.some(
227
218
  (bypass) => bypass.commandName.toLowerCase() === command.toLowerCase() && bypass.userIds.includes(user.id)
228
219
  )) {
229
- return { validated: false, failReason: 8 /* NotBotStaff */ };
220
+ return { validated: true };
221
+ }
222
+ if (inGuild) {
223
+ for (const role of user.roles.cache.values()) {
224
+ if (!user.roles.cache.has(role.id)) {
225
+ missingRoles.push(role.id);
226
+ }
227
+ }
228
+ if (missingRoles.length) {
229
+ return { validated: false, failReason: 8 /* NotBotStaff */, missingRoles };
230
+ } else {
231
+ return { validated: true };
232
+ }
230
233
  }
234
+ return { validated: false, failReason: 8 /* NotBotStaff */ };
231
235
  }
232
236
  return { validated: true };
233
237
  }
@@ -532,12 +536,12 @@ function getProcessDir() {
532
536
  if (!mainPath) return "";
533
537
  return import_node_path.default.dirname(mainPath);
534
538
  }
535
- async function importModulesFromDir(dir, fnPrefix) {
539
+ async function importModulesFromDir(dir, suffix) {
536
540
  const cwd = getProcessDir();
537
541
  const MODULE_RELATIVE_PATH = import_node_path.default.join(cwd, dir);
538
542
  const MODULE_LOG_PATH = dir;
539
543
  const files = import_qznt.$.fs.readDir(MODULE_RELATIVE_PATH).filter(
540
- (fn) => fn.endsWith(`${fnPrefix ? `.${fnPrefix}` : ""}.js`) || fn.endsWith(`${fnPrefix ? `.${fnPrefix}` : ""}.ts`)
544
+ (fn) => fn.endsWith(`${suffix ? `.${suffix}` : ""}.js`) || fn.endsWith(`${suffix ? `.${suffix}` : ""}.ts`)
541
545
  );
542
546
  if (!files.length) {
543
547
  return [];
@@ -976,7 +980,13 @@ var defaultConfig = {
976
980
  name: "Discord Bot",
977
981
  appVersion: "1.0.0",
978
982
  verbose: false,
979
- disableBanner: false
983
+ disableBanner: false,
984
+ moduleSuffixes: {
985
+ slashCommand: "slash",
986
+ contextCommand: "ctx",
987
+ prefixCommand: "prefix",
988
+ event: "event"
989
+ }
980
990
  };
981
991
  function createVimcordAppConfig(options = {}) {
982
992
  return import_lodash6.default.merge(defaultConfig, options);
@@ -1345,7 +1355,7 @@ function formatThousands(num, sep = ",") {
1345
1355
  // src/modules/status.manager.ts
1346
1356
  var import_node_events = __toESM(require("events"));
1347
1357
  var import_qznt2 = require("qznt");
1348
- var VimcordStatusManager = class {
1358
+ var StatusManager = class {
1349
1359
  client;
1350
1360
  logger;
1351
1361
  emitter = new import_node_events.default();
@@ -1467,44 +1477,67 @@ var VimcordStatusManager = class {
1467
1477
 
1468
1478
  // src/modules/command.manager.ts
1469
1479
  var import_discord5 = require("discord.js");
1470
- var VimcordAppCommandManager = class {
1471
- constructor(client, typeName) {
1480
+ var BaseCommandManager = class {
1481
+ type;
1482
+ client;
1483
+ commands = /* @__PURE__ */ new Map();
1484
+ moduleSuffix;
1485
+ constructor(client, type, moduleSuffix) {
1486
+ this.type = type;
1472
1487
  this.client = client;
1473
- this.typeName = typeName;
1474
- this.client.whenReady().then((c) => this.rest = new import_discord5.REST().setToken(c.token));
1488
+ this.moduleSuffix = moduleSuffix;
1475
1489
  }
1476
- commands = /* @__PURE__ */ new Map();
1477
- rest;
1490
+ /**
1491
+ * Gets a command by name.
1492
+ */
1478
1493
  get(name) {
1479
- return this.commands.get(name);
1494
+ if (this.type === 1 /* Prefix */) {
1495
+ const config = this.client.config.prefixCommands;
1496
+ const search = config.allowCaseInsensitiveCommandNames ? name.toLowerCase() : name;
1497
+ return Array.from(this.commands.values()).find((cmd) => {
1498
+ const commandName = "builder" in cmd ? cmd.builder.name : cmd.options.name;
1499
+ const trigger = config.allowCaseInsensitiveCommandNames ? commandName.toLowerCase() : commandName;
1500
+ if (trigger === search) return true;
1501
+ if ("aliases" in cmd.options) {
1502
+ return cmd.options.aliases?.some(
1503
+ (a) => config.allowCaseInsensitiveCommandNames ? a.toLowerCase() === search : a === search
1504
+ );
1505
+ }
1506
+ });
1507
+ } else {
1508
+ return this.commands.get(name);
1509
+ }
1480
1510
  }
1481
1511
  /**
1482
- * Filters and returns commands based on deployment options alphabetically
1512
+ * Gets/filters commands and orders them alphabetically
1483
1513
  */
1484
- getAll(options) {
1514
+ getAll(options = {}) {
1485
1515
  const matchedCommands = /* @__PURE__ */ new Map();
1486
1516
  const isDev = this.client.config.app.devMode;
1487
1517
  for (const cmd of this.commands.values()) {
1488
- const config = cmd.toConfig();
1489
- const name = cmd.builder.name;
1490
- if (options?.names || options?.fuzzyNames) {
1491
- const nameMatched = options.names?.includes(name) || options.fuzzyNames?.some((fuzzy) => name.includes(fuzzy));
1518
+ const commandName = "builder" in cmd ? cmd.builder.name : cmd.options.name;
1519
+ if (options.names || options.fuzzyNames) {
1520
+ const nameMatched = options.names?.includes(commandName) || options.fuzzyNames?.some((fuzzy) => commandName.includes(fuzzy));
1492
1521
  if (!nameMatched) continue;
1493
1522
  }
1494
- if (options?.ignoreDeploymentOptions) {
1495
- matchedCommands.set(name, cmd);
1523
+ if (options.ignoreDeploymentOptions) {
1524
+ matchedCommands.set(commandName, cmd);
1496
1525
  continue;
1497
1526
  }
1498
- const deployment = config.deployment || {};
1527
+ const deployment = "deployment" in cmd.options ? cmd.options.deployment ?? {} : {};
1499
1528
  const isProperEnv = !deployment.environments || deployment.environments.includes(isDev ? "development" : "production");
1500
1529
  if (!isProperEnv) continue;
1501
- if (options?.globalOnly && deployment.global === false) continue;
1502
- matchedCommands.set(name, cmd);
1530
+ if (options.globalOnly && deployment.global === false) continue;
1531
+ matchedCommands.set(commandName, cmd);
1503
1532
  }
1504
- return Array.from(matchedCommands.values()).sort((a, b) => a.builder.name.localeCompare(b.builder.name));
1533
+ return Array.from(matchedCommands.values()).sort((a, b) => {
1534
+ const commandNameA = "builder" in a ? a.builder.name : a.options.name;
1535
+ const commandNameB = "builder" in b ? b.builder.name : b.options.name;
1536
+ return commandNameA.localeCompare(commandNameB);
1537
+ });
1505
1538
  }
1506
1539
  /**
1507
- * Groups commands by category alphabetically
1540
+ * Groups commands by category alphabetically.
1508
1541
  */
1509
1542
  sortByCategory() {
1510
1543
  const categories = /* @__PURE__ */ new Map();
@@ -1523,183 +1556,152 @@ var VimcordAppCommandManager = class {
1523
1556
  entry.commands.push(cmd);
1524
1557
  }
1525
1558
  return Array.from(categories.values()).sort((a, b) => a.name.localeCompare(b.name)).map((cat) => {
1526
- cat.commands.sort((a, b) => a.builder.name.localeCompare(b.builder.name));
1559
+ cat.commands.sort((a, b) => {
1560
+ const commandNameA = "builder" in a ? a.builder.name : a.options.name;
1561
+ const commandNameB = "builder" in b ? b.builder.name : b.options.name;
1562
+ return commandNameA.localeCompare(commandNameB);
1563
+ });
1527
1564
  return cat;
1528
1565
  });
1529
1566
  }
1530
- async registerGlobal(options) {
1567
+ /**
1568
+ * Imports command modules from a directory.
1569
+ * @param dir Path of one or more folders.
1570
+ * @param set Replaces imported command modules with the ones found.
1571
+ */
1572
+ async importFrom(dir, set = false) {
1573
+ if (set) this.commands.clear();
1574
+ const dirs = Array.isArray(dir) ? dir : [dir];
1575
+ const modules = [];
1576
+ for (const _dir of dirs) {
1577
+ const results = await importModulesFromDir(_dir, this.moduleSuffix);
1578
+ modules.push(...results.map(({ module: module2 }) => module2.default));
1579
+ }
1580
+ for (const module2 of modules) {
1581
+ const commandName = "builder" in module2 ? module2.builder.name : module2.options.name;
1582
+ this.commands.set(commandName, module2);
1583
+ }
1584
+ let moduleType;
1585
+ switch (this.type) {
1586
+ case 0 /* Slash */:
1587
+ moduleType = "Prefix Commands";
1588
+ break;
1589
+ case 2 /* Context */:
1590
+ moduleType = "Context Commands";
1591
+ break;
1592
+ case 1 /* Prefix */:
1593
+ moduleType = "Prefix Commands";
1594
+ break;
1595
+ }
1596
+ this.client.logger.moduleLoaded(moduleType, modules.length);
1597
+ return this.commands;
1598
+ }
1599
+ };
1600
+ var SlashCommandManager = class extends BaseCommandManager {
1601
+ constructor(client) {
1602
+ super(client, 0 /* Slash */, client.config.app.moduleSuffixes.slashCommand);
1603
+ }
1604
+ };
1605
+ var ContextCommandManager = class extends BaseCommandManager {
1606
+ constructor(client) {
1607
+ super(client, 2 /* Context */, client.config.app.moduleSuffixes.contextCommand);
1608
+ }
1609
+ };
1610
+ var PrefixCommandManager = class extends BaseCommandManager {
1611
+ constructor(client) {
1612
+ super(client, 1 /* Prefix */, client.config.app.moduleSuffixes.prefixCommand);
1613
+ }
1614
+ };
1615
+ var CommandManager = class {
1616
+ client;
1617
+ slash;
1618
+ prefix;
1619
+ context;
1620
+ constructor(client) {
1621
+ this.client = client;
1622
+ this.slash = new SlashCommandManager(client);
1623
+ this.prefix = new PrefixCommandManager(client);
1624
+ this.context = new ContextCommandManager(client);
1625
+ }
1626
+ getAllAppCommands(options = {}) {
1627
+ return [...this.slash.getAll(options), ...this.context.getAll(options)];
1628
+ }
1629
+ async registerGlobal(options = {}) {
1531
1630
  const client = await this.client.whenReady();
1532
- const commands = Array.from(
1533
- this.getAll({
1534
- names: options?.commands,
1535
- fuzzyNames: options?.fuzzyCommands,
1536
- globalOnly: true
1537
- }).values()
1538
- ).map((cmd) => cmd.builder.toJSON());
1631
+ if (!client.rest) {
1632
+ console.error(`[CommandManager] \u2716 Failed to register app commands globally: REST is not initialized`);
1633
+ return;
1634
+ }
1635
+ const commands = this.getAllAppCommands(options);
1539
1636
  if (!commands.length) {
1540
- console.log(`[${this.typeName}] No commands to register`);
1637
+ console.log("[CommandManager] No commands to register globally");
1541
1638
  return;
1542
1639
  }
1543
- console.log(`[${this.typeName}] Registering ${commands.length} commands globally...`);
1640
+ console.log(`[CommandManager] Registering (${commands.length}) commands globally...`);
1544
1641
  try {
1545
- await this.rest.put(import_discord5.Routes.applicationCommands(client.user.id), { body: commands });
1546
- console.log(`[${this.typeName}] \u2714 Registered app commands globally`);
1642
+ await client.rest.put(import_discord5.Routes.applicationCommands(client.user.id), { body: commands });
1643
+ console.log(`[CommandManager] \u2714 Registered app commands globally`);
1547
1644
  } catch (err) {
1548
- console.log(`[${this.typeName}] \u2716 Failed to register app commands globally`, err);
1645
+ console.error(`[CommandManager] \u2716 Failed to register app commands globally`, err);
1549
1646
  }
1550
1647
  }
1551
- async registerGuild(options) {
1648
+ async unregisterGlobal() {
1552
1649
  const client = await this.client.whenReady();
1553
- const commands = Array.from(
1554
- this.getAll({
1555
- names: options?.commands,
1556
- fuzzyNames: options?.fuzzyCommands
1557
- }).values()
1558
- ).map((cmd) => cmd.builder.toJSON());
1650
+ if (!client.rest) {
1651
+ console.error(`[CommandManager] \u2716 Failed to remove app commands globally: REST is not initialized`);
1652
+ return;
1653
+ }
1654
+ try {
1655
+ await client.rest.put(import_discord5.Routes.applicationCommands(client.user.id), { body: [] });
1656
+ console.log(`[CommandManager] \u2714 Removed app commands globally`);
1657
+ } catch (err) {
1658
+ console.error(`[CommandManager] \u2716 Failed to remove app commands globally`, err);
1659
+ }
1660
+ }
1661
+ async registerGuild(options = {}) {
1662
+ const client = await this.client.whenReady();
1663
+ if (!client.rest) {
1664
+ console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
1665
+ return;
1666
+ }
1667
+ const commands = this.getAllAppCommands(options);
1559
1668
  if (!commands.length) {
1560
- console.log(`[${this.typeName}] No commands to register`);
1669
+ console.log("[CommandManager] No commands to register by guild");
1561
1670
  return;
1562
1671
  }
1563
- const guildIds = options?.guilds || client.guilds.cache.map((g) => g.id);
1564
- console.log(`[${this.typeName}] Registering ${commands.length} commands for ${guildIds.length} guilds...`);
1672
+ const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
1673
+ console.log(`[CommandManager] Registering (${commands.length}) commands for ${guildIds.length} guilds...`);
1565
1674
  await Promise.all(
1566
1675
  guildIds.map(
1567
- (guildId) => this.rest.put(import_discord5.Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
1676
+ (guildId) => client.rest.put(import_discord5.Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
1568
1677
  const gName = client.guilds.cache.get(guildId)?.name || "n/a";
1569
- console.log(`[${this.typeName}] \u2714 Set app commands in guild: ${guildId} (${gName})`);
1678
+ console.log(`[CommandManager] \u2714 Set app commands in guild: ${guildId} (${gName})`);
1570
1679
  }).catch((err) => {
1571
1680
  const gName = client.guilds.cache.get(guildId)?.name || "n/a";
1572
- console.log(`[${this.typeName}] \u2716 Failed to set app commands in guild: ${guildId} (${gName})`, err);
1681
+ console.log(`[CommandManager] \u2716 Failed to set app commands in guild: ${guildId} (${gName})`, err);
1573
1682
  })
1574
1683
  )
1575
1684
  );
1576
1685
  }
1577
- async unregisterGuild(options) {
1686
+ async unregisterGuild(options = {}) {
1578
1687
  const client = await this.client.whenReady();
1579
- const guildIds = options?.guilds || client.guilds.cache.map((g) => g.id);
1580
- console.log(`[${this.typeName}] Unregistering commands from ${guildIds.length} guilds...`);
1688
+ if (!client.rest) {
1689
+ console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
1690
+ return;
1691
+ }
1692
+ const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
1693
+ console.log(`[CommandManager] Unregistering commands from ${guildIds.length} guilds...`);
1581
1694
  await Promise.all(
1582
1695
  guildIds.map(
1583
- (guildId) => this.rest.put(import_discord5.Routes.applicationGuildCommands(client.user.id, guildId), { body: [] }).then(() => console.log(`[${this.typeName}] \u2714 Removed app commands in guild: ${guildId}`)).catch(
1584
- (err) => console.log(`[${this.typeName}] \u2716 Failed to remove app commands in guild: ${guildId}`, err)
1585
- )
1696
+ (guildId) => client.rest.put(import_discord5.Routes.applicationGuildCommands(client.user.id, guildId), { body: [] }).then(() => console.log(`[CommandManager] \u2714 Removed app commands in guild: ${guildId}`)).catch((err) => console.log(`[CommandManager] \u2716 Failed to remove app commands in guild: ${guildId}`, err))
1586
1697
  )
1587
1698
  );
1588
1699
  }
1589
- async unregisterGlobal() {
1590
- const client = await this.client.whenReady();
1591
- try {
1592
- await this.rest.put(import_discord5.Routes.applicationCommands(client.user.id), { body: [] });
1593
- console.log(`[${this.typeName}] \u2714 Removed app commands globally`);
1594
- } catch (err) {
1595
- console.log(`[${this.typeName}] \u2716 Failed to remove app commands globally`, err);
1596
- }
1597
- }
1598
- };
1599
- var VimcordSlashCommandManager = class extends VimcordAppCommandManager {
1600
- constructor(client) {
1601
- super(client, "SlashCommandManager");
1602
- }
1603
- async importFrom(dir, replaceAll = false) {
1604
- if (replaceAll) this.commands.clear();
1605
- const dirs = Array.isArray(dir) ? dir : [dir];
1606
- const modules = (await Promise.all(
1607
- dirs.map((d) => importModulesFromDir(d, "slash"))
1608
- )).flat();
1609
- for (const { module: module2 } of modules) {
1610
- this.commands.set(module2.default.builder.name, module2.default);
1611
- }
1612
- this.client.logger.moduleLoaded("Slash Commands", modules.length);
1613
- return this.commands;
1614
- }
1615
- };
1616
- var VimcordContextCommandManager = class extends VimcordAppCommandManager {
1617
- constructor(client) {
1618
- super(client, "ContextCommandManager");
1619
- }
1620
- async importFrom(dir, replaceAll = false) {
1621
- if (replaceAll) this.commands.clear();
1622
- const dirs = Array.isArray(dir) ? dir : [dir];
1623
- const modules = (await Promise.all(
1624
- dirs.map((d) => importModulesFromDir(d, "ctx"))
1625
- )).flat();
1626
- for (const { module: module2 } of modules) {
1627
- this.commands.set(module2.default.builder.name, module2.default);
1628
- }
1629
- this.client.logger.moduleLoaded("Context Commands", modules.length);
1630
- return this.commands;
1631
- }
1632
- };
1633
- var VimcordPrefixCommandManager = class {
1634
- constructor(client) {
1635
- this.client = client;
1636
- }
1637
- commands = /* @__PURE__ */ new Map();
1638
- resolve(trigger) {
1639
- const config = this.client.config.prefixCommands;
1640
- const search = config.allowCaseInsensitiveCommandNames ? trigger.toLowerCase() : trigger;
1641
- return Array.from(this.commands.values()).find((cmd) => {
1642
- const opts = cmd.toConfig();
1643
- const name = config.allowCaseInsensitiveCommandNames ? opts.name.toLowerCase() : opts.name;
1644
- if (name === search) return true;
1645
- return opts.aliases?.some(
1646
- (a) => config.allowCaseInsensitiveCommandNames ? a.toLowerCase() === search : a === search
1647
- );
1648
- });
1649
- }
1650
- /**
1651
- * Groups commands by category alphabetically
1652
- */
1653
- sortByCategory() {
1654
- const categories = /* @__PURE__ */ new Map();
1655
- for (const cmd of this.commands.values()) {
1656
- const metadata = cmd.options.metadata;
1657
- if (!metadata?.category) continue;
1658
- let entry = categories.get(metadata.category);
1659
- if (!entry) {
1660
- entry = {
1661
- name: metadata.category,
1662
- emoji: metadata.categoryEmoji,
1663
- commands: []
1664
- };
1665
- categories.set(metadata.category, entry);
1666
- }
1667
- entry.commands.push(cmd);
1668
- }
1669
- return Array.from(categories.values()).sort((a, b) => a.name.localeCompare(b.name)).map((cat) => {
1670
- cat.commands.sort((a, b) => a.options.name.localeCompare(b.options.name));
1671
- return cat;
1672
- });
1673
- }
1674
- async importFrom(dir, replaceAll = false) {
1675
- if (replaceAll) this.commands.clear();
1676
- const dirs = Array.isArray(dir) ? dir : [dir];
1677
- const modules = (await Promise.all(
1678
- dirs.map(
1679
- (d) => importModulesFromDir(d, "prefix")
1680
- )
1681
- )).flat();
1682
- for (const { module: module2 } of modules) {
1683
- this.commands.set(module2.default.toConfig().name, module2.default);
1684
- }
1685
- this.client.logger.moduleLoaded("Prefix Commands", modules.length);
1686
- return this.commands;
1687
- }
1688
- };
1689
- var VimcordCommandManager = class {
1690
- slash;
1691
- prefix;
1692
- context;
1693
- constructor(client) {
1694
- this.slash = new VimcordSlashCommandManager(client);
1695
- this.prefix = new VimcordPrefixCommandManager(client);
1696
- this.context = new VimcordContextCommandManager(client);
1697
- }
1698
1700
  };
1699
1701
 
1700
1702
  // src/modules/event.manager.ts
1701
1703
  var import_discord6 = require("discord.js");
1702
- var VimcordEventManager = class {
1704
+ var EventManager = class {
1703
1705
  client;
1704
1706
  events = /* @__PURE__ */ new Map();
1705
1707
  logger;
@@ -2264,7 +2266,7 @@ async function sendCommandErrorEmbed(client, error, guild, messageOrInteraction)
2264
2266
  const embed_error = config?.embed?.(new BetterEmbed(), error, guild) || new BetterEmbed({
2265
2267
  color: "Red",
2266
2268
  title: "Something went wrong",
2267
- description: "If you keep encountering this error, please report it"
2269
+ description: "If you keep encountering this error, please report it."
2268
2270
  });
2269
2271
  const msg = await embed_error.send(messageOrInteraction, {
2270
2272
  components: [actionRow],
@@ -2310,7 +2312,7 @@ async function retryExponentialBackoff(fn, maxRetries = 3, retryDelay = 1e3) {
2310
2312
  }
2311
2313
 
2312
2314
  // package.json
2313
- var version = "1.0.23";
2315
+ var version = "1.0.24";
2314
2316
 
2315
2317
  // src/client.ts
2316
2318
  var import_node_crypto3 = require("crypto");
@@ -2404,9 +2406,9 @@ var Vimcord = class _Vimcord extends import_discord10.Client {
2404
2406
  prefixCommands: createVimcordPrefixCommandConfig(config.prefixCommands),
2405
2407
  contextCommands: createVimcordContextCommandConfig(config.contextCommands)
2406
2408
  };
2407
- this.status = new VimcordStatusManager(this);
2408
- this.events = new VimcordEventManager(this);
2409
- this.commands = new VimcordCommandManager(this);
2409
+ this.status = new StatusManager(this);
2410
+ this.events = new EventManager(this);
2411
+ this.commands = new CommandManager(this);
2410
2412
  if (this.features.useEnv) {
2411
2413
  if (typeof this.features.useEnv === "object") {
2412
2414
  import_dotenv.default.config({ quiet: true, ...this.features.useEnv });
@@ -2605,7 +2607,7 @@ var defaultPrefixCommandHandler = new EventBuilder({
2605
2607
  const args = contentWithoutPrefix.split(/\s+/);
2606
2608
  const trigger = args.shift();
2607
2609
  if (!trigger) return;
2608
- const command = client.commands.prefix.resolve(trigger);
2610
+ const command = client.commands.prefix.get(trigger);
2609
2611
  if (!command) return;
2610
2612
  message.content = args.join(" ");
2611
2613
  try {
@@ -2923,7 +2925,7 @@ var MongoSchemaBuilder = class {
2923
2925
  return this.model.findOne(filter, projection, { ...options, lean: options?.lean ?? true });
2924
2926
  });
2925
2927
  }
2926
- async fetchAll(filter, projection, options) {
2928
+ async fetchAll(filter = {}, projection, options) {
2927
2929
  return await this.execute(async () => {
2928
2930
  return this.model.find(filter, projection, { ...options, lean: options?.lean ?? true });
2929
2931
  }) || [];
@@ -4194,13 +4196,11 @@ CLI.addCommand("register", "Register app commands (slash & context) globally, or
4194
4196
  switch (mode) {
4195
4197
  case "guild":
4196
4198
  CLI.logger.info("Registering guild commands...");
4197
- await client.commands.slash.registerGuild({ guilds: guildIds });
4198
- await client.commands.context.registerGuild({ guilds: guildIds });
4199
+ await client.commands.registerGuild({ guilds: guildIds });
4199
4200
  break;
4200
4201
  case "global":
4201
4202
  CLI.logger.info("Registering global commands...");
4202
- await client.commands.slash.registerGlobal();
4203
- await client.commands.context.registerGlobal();
4203
+ await client.commands.registerGlobal();
4204
4204
  break;
4205
4205
  }
4206
4206
  });
@@ -4216,13 +4216,11 @@ CLI.addCommand("unregister", "Unregister app commands globally, or per guild", a
4216
4216
  switch (mode) {
4217
4217
  case "guild":
4218
4218
  CLI.logger.info("Unregistering guild commands...");
4219
- await client.commands.slash.unregisterGuild({ guilds: guildIds });
4220
- await client.commands.context.unregisterGuild({ guilds: guildIds });
4219
+ await client.commands.unregisterGuild({ guilds: guildIds });
4221
4220
  break;
4222
4221
  case "global":
4223
4222
  CLI.logger.info("Unregistering global commands...");
4224
- await client.commands.slash.unregisterGlobal();
4225
- await client.commands.context.unregisterGlobal();
4223
+ await client.commands.unregisterGlobal();
4226
4224
  break;
4227
4225
  }
4228
4226
  });
@@ -4324,16 +4322,20 @@ function pickRandom(arr, options) {
4324
4322
  // Annotate the CommonJS export names for ESM import in node:
4325
4323
  0 && (module.exports = {
4326
4324
  BaseCommandBuilder,
4325
+ BaseCommandManager,
4327
4326
  BetterCollector,
4328
4327
  BetterContainer,
4329
4328
  BetterEmbed,
4330
4329
  BetterModal,
4331
4330
  CLI,
4332
4331
  CollectorTimeoutType,
4332
+ CommandManager,
4333
4333
  CommandType,
4334
4334
  ContextCommandBuilder,
4335
+ ContextCommandManager,
4335
4336
  DynaSend,
4336
4337
  EventBuilder,
4338
+ EventManager,
4337
4339
  LOGGER_COLORS,
4338
4340
  LogLevel,
4339
4341
  Logger,
@@ -4344,20 +4346,17 @@ function pickRandom(arr, options) {
4344
4346
  PaginationType,
4345
4347
  Paginator,
4346
4348
  PrefixCommandBuilder,
4349
+ PrefixCommandManager,
4347
4350
  Prompt,
4348
4351
  PromptResolveType,
4349
4352
  RateLimitScope,
4350
4353
  SendMethod,
4351
4354
  SlashCommandBuilder,
4355
+ SlashCommandManager,
4356
+ StatusManager,
4352
4357
  StatusType,
4353
4358
  Vimcord,
4354
4359
  VimcordCLI,
4355
- VimcordCommandManager,
4356
- VimcordContextCommandManager,
4357
- VimcordEventManager,
4358
- VimcordPrefixCommandManager,
4359
- VimcordSlashCommandManager,
4360
- VimcordStatusManager,
4361
4360
  __zero,
4362
4361
  cleanMention,
4363
4362
  clientInstances,