vimcord 1.0.22 → 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 };
230
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
+ }
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 [];
@@ -767,8 +771,9 @@ var EventBuilder = class _EventBuilder {
767
771
 
768
772
  // src/builders/prefixCommand.builder.ts
769
773
  var PrefixCommandBuilder = class extends BaseCommandBuilder {
770
- constructor(config) {
771
- super(1 /* Prefix */, config);
774
+ constructor(options) {
775
+ super(1 /* Prefix */, options);
776
+ this.options = options;
772
777
  const originalExecute = this.options.execute;
773
778
  this.options.execute = async (client, message) => {
774
779
  return await this.handleExecution(client, message, originalExecute);
@@ -975,7 +980,13 @@ var defaultConfig = {
975
980
  name: "Discord Bot",
976
981
  appVersion: "1.0.0",
977
982
  verbose: false,
978
- disableBanner: false
983
+ disableBanner: false,
984
+ moduleSuffixes: {
985
+ slashCommand: "slash",
986
+ contextCommand: "ctx",
987
+ prefixCommand: "prefix",
988
+ event: "event"
989
+ }
979
990
  };
980
991
  function createVimcordAppConfig(options = {}) {
981
992
  return import_lodash6.default.merge(defaultConfig, options);
@@ -1344,7 +1355,7 @@ function formatThousands(num, sep = ",") {
1344
1355
  // src/modules/status.manager.ts
1345
1356
  var import_node_events = __toESM(require("events"));
1346
1357
  var import_qznt2 = require("qznt");
1347
- var VimcordStatusManager = class {
1358
+ var StatusManager = class {
1348
1359
  client;
1349
1360
  logger;
1350
1361
  emitter = new import_node_events.default();
@@ -1466,191 +1477,231 @@ var VimcordStatusManager = class {
1466
1477
 
1467
1478
  // src/modules/command.manager.ts
1468
1479
  var import_discord5 = require("discord.js");
1469
- var VimcordAppCommandManager = class {
1470
- 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;
1471
1487
  this.client = client;
1472
- this.typeName = typeName;
1473
- this.client.whenReady().then((c) => this.rest = new import_discord5.REST().setToken(c.token));
1488
+ this.moduleSuffix = moduleSuffix;
1474
1489
  }
1475
- commands = /* @__PURE__ */ new Map();
1476
- rest;
1490
+ /**
1491
+ * Gets a command by name.
1492
+ */
1477
1493
  get(name) {
1478
- 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
+ }
1479
1510
  }
1480
1511
  /**
1481
- * Filters and returns commands based on deployment options
1512
+ * Gets/filters commands and orders them alphabetically
1482
1513
  */
1483
- getAll(options) {
1514
+ getAll(options = {}) {
1484
1515
  const matchedCommands = /* @__PURE__ */ new Map();
1485
1516
  const isDev = this.client.config.app.devMode;
1486
1517
  for (const cmd of this.commands.values()) {
1487
- const config = cmd.toConfig();
1488
- const name = cmd.builder.name;
1489
- if (options?.names || options?.fuzzyNames) {
1490
- 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));
1491
1521
  if (!nameMatched) continue;
1492
1522
  }
1493
- if (options?.ignoreDeploymentOptions) {
1494
- matchedCommands.set(name, cmd);
1523
+ if (options.ignoreDeploymentOptions) {
1524
+ matchedCommands.set(commandName, cmd);
1495
1525
  continue;
1496
1526
  }
1497
- const deployment = config.deployment || {};
1527
+ const deployment = "deployment" in cmd.options ? cmd.options.deployment ?? {} : {};
1498
1528
  const isProperEnv = !deployment.environments || deployment.environments.includes(isDev ? "development" : "production");
1499
1529
  if (!isProperEnv) continue;
1500
- if (options?.globalOnly && deployment.global === false) continue;
1501
- matchedCommands.set(name, cmd);
1530
+ if (options.globalOnly && deployment.global === false) continue;
1531
+ matchedCommands.set(commandName, cmd);
1532
+ }
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
+ });
1538
+ }
1539
+ /**
1540
+ * Groups commands by category alphabetically.
1541
+ */
1542
+ sortByCategory() {
1543
+ const categories = /* @__PURE__ */ new Map();
1544
+ for (const cmd of this.commands.values()) {
1545
+ const metadata = cmd.options.metadata;
1546
+ if (!metadata?.category) continue;
1547
+ let entry = categories.get(metadata.category);
1548
+ if (!entry) {
1549
+ entry = {
1550
+ name: metadata.category,
1551
+ emoji: metadata.categoryEmoji,
1552
+ commands: []
1553
+ };
1554
+ categories.set(metadata.category, entry);
1555
+ }
1556
+ entry.commands.push(cmd);
1502
1557
  }
1503
- return matchedCommands;
1558
+ return Array.from(categories.values()).sort((a, b) => a.name.localeCompare(b.name)).map((cat) => {
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
+ });
1564
+ return cat;
1565
+ });
1566
+ }
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)];
1504
1628
  }
1505
- async registerGlobal(options) {
1629
+ async registerGlobal(options = {}) {
1506
1630
  const client = await this.client.whenReady();
1507
- const commands = Array.from(
1508
- this.getAll({
1509
- names: options?.commands,
1510
- fuzzyNames: options?.fuzzyCommands,
1511
- globalOnly: true
1512
- }).values()
1513
- ).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);
1514
1636
  if (!commands.length) {
1515
- console.log(`[${this.typeName}] No commands to register`);
1637
+ console.log("[CommandManager] No commands to register globally");
1516
1638
  return;
1517
1639
  }
1518
- console.log(`[${this.typeName}] Registering ${commands.length} commands globally...`);
1640
+ console.log(`[CommandManager] Registering (${commands.length}) commands globally...`);
1519
1641
  try {
1520
- await this.rest.put(import_discord5.Routes.applicationCommands(client.user.id), { body: commands });
1521
- 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`);
1522
1644
  } catch (err) {
1523
- console.log(`[${this.typeName}] \u2716 Failed to register app commands globally`, err);
1645
+ console.error(`[CommandManager] \u2716 Failed to register app commands globally`, err);
1524
1646
  }
1525
1647
  }
1526
- async registerGuild(options) {
1648
+ async unregisterGlobal() {
1527
1649
  const client = await this.client.whenReady();
1528
- const commands = Array.from(
1529
- this.getAll({
1530
- names: options?.commands,
1531
- fuzzyNames: options?.fuzzyCommands
1532
- }).values()
1533
- ).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);
1534
1668
  if (!commands.length) {
1535
- console.log(`[${this.typeName}] No commands to register`);
1669
+ console.log("[CommandManager] No commands to register by guild");
1536
1670
  return;
1537
1671
  }
1538
- const guildIds = options?.guilds || client.guilds.cache.map((g) => g.id);
1539
- 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...`);
1540
1674
  await Promise.all(
1541
1675
  guildIds.map(
1542
- (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(() => {
1543
1677
  const gName = client.guilds.cache.get(guildId)?.name || "n/a";
1544
- console.log(`[${this.typeName}] \u2714 Set app commands in guild: ${guildId} (${gName})`);
1678
+ console.log(`[CommandManager] \u2714 Set app commands in guild: ${guildId} (${gName})`);
1545
1679
  }).catch((err) => {
1546
1680
  const gName = client.guilds.cache.get(guildId)?.name || "n/a";
1547
- 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);
1548
1682
  })
1549
1683
  )
1550
1684
  );
1551
1685
  }
1552
- async unregisterGuild(options) {
1686
+ async unregisterGuild(options = {}) {
1553
1687
  const client = await this.client.whenReady();
1554
- const guildIds = options?.guilds || client.guilds.cache.map((g) => g.id);
1555
- 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...`);
1556
1694
  await Promise.all(
1557
1695
  guildIds.map(
1558
- (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(
1559
- (err) => console.log(`[${this.typeName}] \u2716 Failed to remove app commands in guild: ${guildId}`, err)
1560
- )
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))
1561
1697
  )
1562
1698
  );
1563
1699
  }
1564
- async unregisterGlobal() {
1565
- const client = await this.client.whenReady();
1566
- try {
1567
- await this.rest.put(import_discord5.Routes.applicationCommands(client.user.id), { body: [] });
1568
- console.log(`[${this.typeName}] \u2714 Removed app commands globally`);
1569
- } catch (err) {
1570
- console.log(`[${this.typeName}] \u2716 Failed to remove app commands globally`, err);
1571
- }
1572
- }
1573
- };
1574
- var VimcordSlashCommandManager = class extends VimcordAppCommandManager {
1575
- constructor(client) {
1576
- super(client, "SlashCommandManager");
1577
- }
1578
- async importFrom(dir, replaceAll = false) {
1579
- if (replaceAll) this.commands.clear();
1580
- const dirs = Array.isArray(dir) ? dir : [dir];
1581
- const modules = (await Promise.all(
1582
- dirs.map((d) => importModulesFromDir(d, "slash"))
1583
- )).flat();
1584
- for (const { module: module2 } of modules) {
1585
- this.commands.set(module2.default.builder.name, module2.default);
1586
- }
1587
- this.client.logger.moduleLoaded("Slash Commands", modules.length);
1588
- return this.commands;
1589
- }
1590
- };
1591
- var VimcordContextCommandManager = class extends VimcordAppCommandManager {
1592
- constructor(client) {
1593
- super(client, "ContextCommandManager");
1594
- }
1595
- async importFrom(dir, replaceAll = false) {
1596
- if (replaceAll) this.commands.clear();
1597
- const dirs = Array.isArray(dir) ? dir : [dir];
1598
- const modules = (await Promise.all(
1599
- dirs.map((d) => importModulesFromDir(d, "ctx"))
1600
- )).flat();
1601
- for (const { module: module2 } of modules) {
1602
- this.commands.set(module2.default.builder.name, module2.default);
1603
- }
1604
- this.client.logger.moduleLoaded("Context Commands", modules.length);
1605
- return this.commands;
1606
- }
1607
- };
1608
- var VimcordPrefixCommandManager = class {
1609
- constructor(client) {
1610
- this.client = client;
1611
- }
1612
- commands = /* @__PURE__ */ new Map();
1613
- resolve(trigger) {
1614
- const config = this.client.config.prefixCommands;
1615
- const search = config.allowCaseInsensitiveCommandNames ? trigger.toLowerCase() : trigger;
1616
- return Array.from(this.commands.values()).find((cmd) => {
1617
- const opts = cmd.toConfig();
1618
- const name = config.allowCaseInsensitiveCommandNames ? opts.name.toLowerCase() : opts.name;
1619
- if (name === search) return true;
1620
- return opts.aliases?.some(
1621
- (a) => config.allowCaseInsensitiveCommandNames ? a.toLowerCase() === search : a === search
1622
- );
1623
- });
1624
- }
1625
- async importFrom(dir, replaceAll = false) {
1626
- if (replaceAll) this.commands.clear();
1627
- const dirs = Array.isArray(dir) ? dir : [dir];
1628
- const modules = (await Promise.all(
1629
- dirs.map(
1630
- (d) => importModulesFromDir(d, "prefix")
1631
- )
1632
- )).flat();
1633
- for (const { module: module2 } of modules) {
1634
- this.commands.set(module2.default.toConfig().name, module2.default);
1635
- }
1636
- this.client.logger.moduleLoaded("Prefix Commands", modules.length);
1637
- return this.commands;
1638
- }
1639
- };
1640
- var VimcordCommandManager = class {
1641
- slash;
1642
- prefix;
1643
- context;
1644
- constructor(client) {
1645
- this.slash = new VimcordSlashCommandManager(client);
1646
- this.prefix = new VimcordPrefixCommandManager(client);
1647
- this.context = new VimcordContextCommandManager(client);
1648
- }
1649
1700
  };
1650
1701
 
1651
1702
  // src/modules/event.manager.ts
1652
1703
  var import_discord6 = require("discord.js");
1653
- var VimcordEventManager = class {
1704
+ var EventManager = class {
1654
1705
  client;
1655
1706
  events = /* @__PURE__ */ new Map();
1656
1707
  logger;
@@ -2215,7 +2266,7 @@ async function sendCommandErrorEmbed(client, error, guild, messageOrInteraction)
2215
2266
  const embed_error = config?.embed?.(new BetterEmbed(), error, guild) || new BetterEmbed({
2216
2267
  color: "Red",
2217
2268
  title: "Something went wrong",
2218
- description: "If you keep encountering this error, please report it"
2269
+ description: "If you keep encountering this error, please report it."
2219
2270
  });
2220
2271
  const msg = await embed_error.send(messageOrInteraction, {
2221
2272
  components: [actionRow],
@@ -2261,7 +2312,7 @@ async function retryExponentialBackoff(fn, maxRetries = 3, retryDelay = 1e3) {
2261
2312
  }
2262
2313
 
2263
2314
  // package.json
2264
- var version = "1.0.22";
2315
+ var version = "1.0.24";
2265
2316
 
2266
2317
  // src/client.ts
2267
2318
  var import_node_crypto3 = require("crypto");
@@ -2355,9 +2406,9 @@ var Vimcord = class _Vimcord extends import_discord10.Client {
2355
2406
  prefixCommands: createVimcordPrefixCommandConfig(config.prefixCommands),
2356
2407
  contextCommands: createVimcordContextCommandConfig(config.contextCommands)
2357
2408
  };
2358
- this.status = new VimcordStatusManager(this);
2359
- this.events = new VimcordEventManager(this);
2360
- this.commands = new VimcordCommandManager(this);
2409
+ this.status = new StatusManager(this);
2410
+ this.events = new EventManager(this);
2411
+ this.commands = new CommandManager(this);
2361
2412
  if (this.features.useEnv) {
2362
2413
  if (typeof this.features.useEnv === "object") {
2363
2414
  import_dotenv.default.config({ quiet: true, ...this.features.useEnv });
@@ -2556,7 +2607,7 @@ var defaultPrefixCommandHandler = new EventBuilder({
2556
2607
  const args = contentWithoutPrefix.split(/\s+/);
2557
2608
  const trigger = args.shift();
2558
2609
  if (!trigger) return;
2559
- const command = client.commands.prefix.resolve(trigger);
2610
+ const command = client.commands.prefix.get(trigger);
2560
2611
  if (!command) return;
2561
2612
  message.content = args.join(" ");
2562
2613
  try {
@@ -2874,7 +2925,7 @@ var MongoSchemaBuilder = class {
2874
2925
  return this.model.findOne(filter, projection, { ...options, lean: options?.lean ?? true });
2875
2926
  });
2876
2927
  }
2877
- async fetchAll(filter, projection, options) {
2928
+ async fetchAll(filter = {}, projection, options) {
2878
2929
  return await this.execute(async () => {
2879
2930
  return this.model.find(filter, projection, { ...options, lean: options?.lean ?? true });
2880
2931
  }) || [];
@@ -4145,13 +4196,11 @@ CLI.addCommand("register", "Register app commands (slash & context) globally, or
4145
4196
  switch (mode) {
4146
4197
  case "guild":
4147
4198
  CLI.logger.info("Registering guild commands...");
4148
- await client.commands.slash.registerGuild({ guilds: guildIds });
4149
- await client.commands.context.registerGuild({ guilds: guildIds });
4199
+ await client.commands.registerGuild({ guilds: guildIds });
4150
4200
  break;
4151
4201
  case "global":
4152
4202
  CLI.logger.info("Registering global commands...");
4153
- await client.commands.slash.registerGlobal();
4154
- await client.commands.context.registerGlobal();
4203
+ await client.commands.registerGlobal();
4155
4204
  break;
4156
4205
  }
4157
4206
  });
@@ -4167,13 +4216,11 @@ CLI.addCommand("unregister", "Unregister app commands globally, or per guild", a
4167
4216
  switch (mode) {
4168
4217
  case "guild":
4169
4218
  CLI.logger.info("Unregistering guild commands...");
4170
- await client.commands.slash.unregisterGuild({ guilds: guildIds });
4171
- await client.commands.context.unregisterGuild({ guilds: guildIds });
4219
+ await client.commands.unregisterGuild({ guilds: guildIds });
4172
4220
  break;
4173
4221
  case "global":
4174
4222
  CLI.logger.info("Unregistering global commands...");
4175
- await client.commands.slash.unregisterGlobal();
4176
- await client.commands.context.unregisterGlobal();
4223
+ await client.commands.unregisterGlobal();
4177
4224
  break;
4178
4225
  }
4179
4226
  });
@@ -4275,16 +4322,20 @@ function pickRandom(arr, options) {
4275
4322
  // Annotate the CommonJS export names for ESM import in node:
4276
4323
  0 && (module.exports = {
4277
4324
  BaseCommandBuilder,
4325
+ BaseCommandManager,
4278
4326
  BetterCollector,
4279
4327
  BetterContainer,
4280
4328
  BetterEmbed,
4281
4329
  BetterModal,
4282
4330
  CLI,
4283
4331
  CollectorTimeoutType,
4332
+ CommandManager,
4284
4333
  CommandType,
4285
4334
  ContextCommandBuilder,
4335
+ ContextCommandManager,
4286
4336
  DynaSend,
4287
4337
  EventBuilder,
4338
+ EventManager,
4288
4339
  LOGGER_COLORS,
4289
4340
  LogLevel,
4290
4341
  Logger,
@@ -4295,20 +4346,17 @@ function pickRandom(arr, options) {
4295
4346
  PaginationType,
4296
4347
  Paginator,
4297
4348
  PrefixCommandBuilder,
4349
+ PrefixCommandManager,
4298
4350
  Prompt,
4299
4351
  PromptResolveType,
4300
4352
  RateLimitScope,
4301
4353
  SendMethod,
4302
4354
  SlashCommandBuilder,
4355
+ SlashCommandManager,
4356
+ StatusManager,
4303
4357
  StatusType,
4304
4358
  Vimcord,
4305
4359
  VimcordCLI,
4306
- VimcordCommandManager,
4307
- VimcordContextCommandManager,
4308
- VimcordEventManager,
4309
- VimcordPrefixCommandManager,
4310
- VimcordSlashCommandManager,
4311
- VimcordStatusManager,
4312
4360
  __zero,
4313
4361
  cleanMention,
4314
4362
  clientInstances,