vimcord 1.0.55 → 1.0.57

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.d.mts CHANGED
@@ -113,7 +113,9 @@ interface BaseCommandConfig<T extends CommandType> {
113
113
  /** Log whenever a command is executed? @defaultValue true */
114
114
  logExecution?: boolean;
115
115
  /** Executed before the main command logic */
116
- beforeExecute?: (...args: BaseCommandParameters<T>) => any;
116
+ beforeExecute?: (ctx: {
117
+ cancel: () => void;
118
+ }, ...args: BaseCommandParameters<T>) => any;
117
119
  /** The main command function that will be executed */
118
120
  execute?: (...args: BaseCommandParameters<T>) => any;
119
121
  /** Executed after successful execution */
@@ -956,7 +958,9 @@ declare const createContextCommandConfig: (options?: {
956
958
  onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
957
959
  } | undefined;
958
960
  logExecution?: boolean | undefined;
959
- beforeExecute?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
961
+ beforeExecute?: ((ctx: {
962
+ cancel: () => void;
963
+ }, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
960
964
  execute?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
961
965
  afterExecute?: ((result: any, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
962
966
  onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
@@ -1321,7 +1325,9 @@ declare const createPrefixCommandConfig: (options?: {
1321
1325
  onRateLimit?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1322
1326
  } | undefined;
1323
1327
  logExecution?: boolean | undefined;
1324
- beforeExecute?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1328
+ beforeExecute?: ((ctx: {
1329
+ cancel: () => void;
1330
+ }, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1325
1331
  execute?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1326
1332
  afterExecute?: ((result: any, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1327
1333
  onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
@@ -1671,7 +1677,9 @@ declare const createSlashCommandConfig: (options?: {
1671
1677
  onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1672
1678
  } | undefined;
1673
1679
  logExecution?: boolean | undefined;
1674
- beforeExecute?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1680
+ beforeExecute?: ((ctx: {
1681
+ cancel: () => void;
1682
+ }, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1675
1683
  execute?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1676
1684
  afterExecute?: ((result: any, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1677
1685
  onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
package/dist/index.d.ts CHANGED
@@ -113,7 +113,9 @@ interface BaseCommandConfig<T extends CommandType> {
113
113
  /** Log whenever a command is executed? @defaultValue true */
114
114
  logExecution?: boolean;
115
115
  /** Executed before the main command logic */
116
- beforeExecute?: (...args: BaseCommandParameters<T>) => any;
116
+ beforeExecute?: (ctx: {
117
+ cancel: () => void;
118
+ }, ...args: BaseCommandParameters<T>) => any;
117
119
  /** The main command function that will be executed */
118
120
  execute?: (...args: BaseCommandParameters<T>) => any;
119
121
  /** Executed after successful execution */
@@ -956,7 +958,9 @@ declare const createContextCommandConfig: (options?: {
956
958
  onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
957
959
  } | undefined;
958
960
  logExecution?: boolean | undefined;
959
- beforeExecute?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
961
+ beforeExecute?: ((ctx: {
962
+ cancel: () => void;
963
+ }, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
960
964
  execute?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
961
965
  afterExecute?: ((result: any, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
962
966
  onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
@@ -1321,7 +1325,9 @@ declare const createPrefixCommandConfig: (options?: {
1321
1325
  onRateLimit?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1322
1326
  } | undefined;
1323
1327
  logExecution?: boolean | undefined;
1324
- beforeExecute?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1328
+ beforeExecute?: ((ctx: {
1329
+ cancel: () => void;
1330
+ }, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1325
1331
  execute?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1326
1332
  afterExecute?: ((result: any, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
1327
1333
  onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
@@ -1671,7 +1677,9 @@ declare const createSlashCommandConfig: (options?: {
1671
1677
  onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1672
1678
  } | undefined;
1673
1679
  logExecution?: boolean | undefined;
1674
- beforeExecute?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1680
+ beforeExecute?: ((ctx: {
1681
+ cancel: () => void;
1682
+ }, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1675
1683
  execute?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1676
1684
  afterExecute?: ((result: any, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
1677
1685
  onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
package/dist/index.js CHANGED
@@ -204,6 +204,8 @@ var BaseCommandBuilder = class {
204
204
  async run(client, ...args) {
205
205
  const config = this.resolveConfig(client);
206
206
  const ctx = this.extractContext(args);
207
+ let canceled = false;
208
+ const cancel = () => canceled = true;
207
209
  try {
208
210
  if (!config.enabled) {
209
211
  return await config.onUsedWhenDisabled?.(...args);
@@ -218,7 +220,10 @@ var BaseCommandBuilder = class {
218
220
  if (!await this.checkConditions(config, ...args)) {
219
221
  return await config.onConditionsNotMet?.(...args);
220
222
  }
221
- await config.beforeExecute?.(...args);
223
+ if (config.beforeExecute) {
224
+ await config.beforeExecute?.({ cancel }, ...args);
225
+ if (canceled) return;
226
+ }
222
227
  if (config.logExecution !== false) {
223
228
  const cmdName = this.options.name || this.builder?.name || "Unknown";
224
229
  const location = ctx.guild ? `${ctx.guild.name} (${ctx.guild.id})` : "Direct Messages";
@@ -1696,7 +1701,7 @@ var VimcordErrorHandler = class {
1696
1701
  import chalk2 from "chalk";
1697
1702
 
1698
1703
  // package.json
1699
- var version = "1.0.55";
1704
+ var version = "1.0.57";
1700
1705
 
1701
1706
  // src/client/vimcord.logger.ts
1702
1707
  var clientLoggerFactory = (client) => new Logger({ prefixEmoji: "\u26A1", prefix: `vimcord (i${client.clientId})` }).extend({
@@ -3213,7 +3218,7 @@ var BetterCollector = class _BetterCollector {
3213
3218
  if (!this.message) return;
3214
3219
  if (this.collector) return;
3215
3220
  this.collector = this.message.createMessageComponentCollector({
3216
- idle: this.options?.idle ?? this.config.timeouts.collectorIdle,
3221
+ idle: this.options?.timeout ? void 0 : this.options?.idle ?? this.config.timeouts.collectorIdle,
3217
3222
  time: this.options?.timeout ?? this.config.timeouts.collectorTimeout,
3218
3223
  componentType: this.options?.type,
3219
3224
  max: this.options?.max,