oft-agt 0.5.8 → 0.5.9

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "oft-agt",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "oft-agt",
9
- "version": "0.5.8",
9
+ "version": "0.5.9",
10
10
  "dependencies": {
11
11
  "discord.js": "^14.14.0",
12
12
  "ws": "^8.18.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oft-agt",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -92,7 +92,7 @@ async function executeAdmitted(command, interaction, client, options) {
92
92
  })();
93
93
  if (!interaction.eventTrigger) await interaction.deferReply(privateAck ? { flags: 64 } : {});
94
94
  if (options.signal.aborted) throw options.signal.reason;
95
- const context = { interaction, client, messages: new Map(options.buttonSnapshot?.messages), channels: new Map(options.buttonSnapshot?.channels), hasCommandReply: false, signal: options.signal || AbortSignal.timeout(870000), variableStore: options.variableStore, variableReplyMode: usesCustomVariables };
95
+ const context = { interaction, client, messages: new Map(options.buttonSnapshot?.messages), channels: new Map(options.buttonSnapshot?.channels), hasCommandReply: false, signal: options.signal || AbortSignal.timeout(870000), variableStore: options.variableStore, ackEphemeral: privateAck };
96
96
  const definitions = options.variableDefinitions || [];
97
97
  const warn = code => options.onWarning?.(code);
98
98
  context.variableOptions = variableRuntimeOptions(context, optionValues, definitions, options.variableStore, warn);
@@ -101,8 +101,18 @@ async function sendMessage(context, parameters) {
101
101
 
102
102
  if (!context.hasCommandReply) {
103
103
 
104
- const message = context.variableReplyMode && !config.ephemeral ? await interaction.followUp({ ...payload, flags: 0 }) : await interaction.editReply(payload);
105
- if (context.variableReplyMode && !config.ephemeral) context.removeDeferredReply = true;
104
+ // Discord treats the first follow-up after a defer as an edit of that
105
+ // acknowledgement, preserving its visibility. Complete it before sending
106
+ // a separate response whose visibility differs from the acknowledgement.
107
+ const differentVisibility = context.ackEphemeral !== undefined
108
+ ? context.ackEphemeral !== config.ephemeral
109
+ : context.variableReplyMode && !config.ephemeral;
110
+ let message;
111
+ if (differentVisibility) {
112
+ await interaction.editReply({ content: '\u200b', embeds: [], components: [] });
113
+ context.removeDeferredReply = true;
114
+ message = await interaction.followUp({ ...payload, flags: config.ephemeral ? 64 : 0 });
115
+ } else message = await interaction.editReply(payload);
106
116
 
107
117
  context.hasCommandReply = true;
108
118
 
package/version.mjs CHANGED
@@ -1 +1 @@
1
- export const AGENT_VERSION = '0.5.8';
1
+ export const AGENT_VERSION = '0.5.9';