oft-agt 0.5.9 → 0.5.10
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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/runtime/execute.mjs +27 -6
- package/version.mjs +1 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oft-agt",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "oft-agt",
|
|
9
|
-
"version": "0.5.
|
|
9
|
+
"version": "0.5.10",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"discord.js": "^14.14.0",
|
|
12
12
|
"ws": "^8.18.0"
|
package/package.json
CHANGED
package/runtime/execute.mjs
CHANGED
|
@@ -84,12 +84,33 @@ async function executeAdmitted(command, interaction, client, options) {
|
|
|
84
84
|
const optionValues = { ...(options.buttonSnapshot?.variables || resolveOptions(command.options, interaction)), ...contextVariables(interaction, client), ...(options.contextVariables || {}) };
|
|
85
85
|
|
|
86
86
|
optionValues.command_name=command.name;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
// Visibility belongs to the configured reply, not to its use of variables.
|
|
88
|
+
// Inspect possible first replies without reading variables, running actions
|
|
89
|
+
// or drawing random branches before execution. A private first reply on any
|
|
90
|
+
// path keeps mixed-visibility commands private until their branch is known.
|
|
91
|
+
function firstReplies(calls) {
|
|
92
|
+
const visibility = new Set();
|
|
93
|
+
for (const call of calls) {
|
|
94
|
+
if (call.fn === 'sendMessage' && (call.args.sendMode || 'reply') === 'reply' && (call.args.replyMode || 'command') === 'command') {
|
|
95
|
+
visibility.add(Boolean(call.args.ephemeral));
|
|
96
|
+
return { visibility, fallsThrough: false };
|
|
97
|
+
}
|
|
98
|
+
if (call.fn === 'condition') {
|
|
99
|
+
let branches = [...call.branches, call.otherwise];
|
|
100
|
+
if (call.args.kind !== 'randomCondition' && !referencedVariables(call.args).length) {
|
|
101
|
+
const args = interpolateOptions(call.args, optionValues);
|
|
102
|
+
const index = selectConditionBranch(args.kind, args.rules, interaction);
|
|
103
|
+
branches = [index < 0 ? call.otherwise : call.branches[index]];
|
|
104
|
+
}
|
|
105
|
+
const paths = branches.map(branch => firstReplies(branch.calls));
|
|
106
|
+
for (const path of paths) for (const value of path.visibility) visibility.add(value);
|
|
107
|
+
if (!paths.some(path => path.fallsThrough)) return { visibility, fallsThrough: false };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { visibility, fallsThrough: true };
|
|
111
|
+
}
|
|
112
|
+
const { visibility } = firstReplies(command.calls);
|
|
113
|
+
const privateAck = !visibility.size || visibility.has(true);
|
|
93
114
|
if (!interaction.eventTrigger) await interaction.deferReply(privateAck ? { flags: 64 } : {});
|
|
94
115
|
if (options.signal.aborted) throw options.signal.reason;
|
|
95
116
|
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 };
|
package/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_VERSION = '0.5.
|
|
1
|
+
export const AGENT_VERSION = '0.5.10';
|