chrxmaticc-framework 1.2.1 → 1.4.0

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.
@@ -52,7 +52,6 @@ class ChrxCommandBuilder {
52
52
  });
53
53
  }
54
54
 
55
- // ── Critical: expose data and execute so CommandLoader + deploy-commands picks it up ──
56
55
  this.data = builder;
57
56
  this.execute = this._execute.bind(this);
58
57
  }
@@ -61,20 +60,24 @@ class ChrxCommandBuilder {
61
60
  const client = interaction.client;
62
61
  const opts = this._options;
63
62
 
63
+ // ── Guild only ────────────────────────────────────────────────────────
64
64
  if (opts.guildOnly !== false && !interaction.guild) {
65
65
  return interaction.reply({ content: "❌ This command can only be used in a server.", ephemeral: true });
66
66
  }
67
67
 
68
+ // ── Owner only ────────────────────────────────────────────────────────
68
69
  if (opts.ownerOnly && interaction.user.id !== process.env.OWNER_ID) {
69
70
  return interaction.reply({ content: "❌ This command is restricted to the bot owner.", ephemeral: true });
70
71
  }
71
72
 
73
+ // ── Permission check ──────────────────────────────────────────────────
72
74
  if (opts.permission) {
73
75
  if (!interaction.member?.permissions.has(PermissionFlagsBits[opts.permission])) {
74
76
  return interaction.reply({ content: `❌ You need the **${opts.permission}** permission to use this.`, ephemeral: true });
75
77
  }
76
78
  }
77
79
 
80
+ // ── Cooldown ──────────────────────────────────────────────────────────
78
81
  if (opts.cooldown) {
79
82
  const key = `${interaction.user.id}-${opts.name}`;
80
83
  const now = Date.now();
@@ -91,6 +94,18 @@ class ChrxCommandBuilder {
91
94
  setTimeout(() => this._cooldowns.delete(key), opts.cooldown * 1000);
92
95
  }
93
96
 
97
+ // ── TimedReply — auto defer if timedReply option is set ───────────────
98
+ if (opts.timedReply) {
99
+ const minutes = opts.timedReply.minutes ?? 1;
100
+ const ms = Math.min(minutes * 60 * 1000, 15 * 60 * 1000); // Discord hard cap is 15min
101
+ if (ms > 2500) {
102
+ // Only defer if we expect the command to take longer than ~2.5s
103
+ await interaction.deferReply({ ephemeral: opts.timedReply.ephemeral ?? false });
104
+ }
105
+ console.log(`[ChrxCommand] /${opts.name} timedReply active — ${minutes}min window`);
106
+ }
107
+
108
+ // ── Plugin injection ──────────────────────────────────────────────────
94
109
  const plugins = {
95
110
  economy: client.chrx?.economy,
96
111
  moderation: client.chrx?.moderation,
@@ -106,6 +121,7 @@ class ChrxCommandBuilder {
106
121
  db: client.db,
107
122
  };
108
123
 
124
+ // ── Run ───────────────────────────────────────────────────────────────
109
125
  try {
110
126
  await opts.run(interaction, plugins);
111
127
  } catch (err) {