Skip to content

Commit 102ca56

Browse files
committed
fix(commands/util/walkthrough): reorder log embed when editing, hide it while editing platform
1 parent 24ce738 commit 102ca56

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

src/commands/util/walkthrough.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ async function buildMessage(
170170
// unanswered step. Otherwise ask the next question if any remain.
171171
const step =
172172
editIndex !== undefined ? steps[editIndex] : steps[values.length];
173+
const question: (
174+
| ContainerBuilder
175+
| ActionRowBuilder<MessageActionRowComponentBuilder>
176+
)[] = [];
173177
if (step) {
174178
const prompt =
175179
editIndex !== undefined
@@ -180,23 +184,33 @@ async function buildMessage(
180184
? [CUSTOM_ID, "edit", editIndex, ...values].join(":")
181185
: [CUSTOM_ID, ...values].join(":");
182186

183-
components.push(
187+
question.push(
184188
new ContainerBuilder()
185189
.setAccentColor(Colors.Blurple)
186190
.addTextDisplayComponents(text(prompt)),
187191
row(StringSelectMenuBuilder.from(step.menu).setCustomId(selectId)),
188192
);
189193
}
190194

191-
const logHint = logLocations[values[1]]?.[values[2]];
192-
if (logHint) {
193-
components.push(
194-
new ContainerBuilder()
195+
// The log locations depend on the platform, so hide them while that answer is
196+
// being edited. When editing another field, show them above the question.
197+
const logHint =
198+
editIndex === 2 ? undefined : logLocations[values[1]]?.[values[2]];
199+
const logComponent = logHint
200+
? new ContainerBuilder()
195201
.setAccentColor(Colors.Blurple)
196202
.addTextDisplayComponents(
197203
text(`**Where to find your logs**\n${logHint}`),
198-
),
199-
);
204+
)
205+
: undefined;
206+
207+
if (editIndex !== undefined && logComponent) {
208+
components.push(logComponent, ...question);
209+
} else {
210+
components.push(...question);
211+
if (logComponent) {
212+
components.push(logComponent);
213+
}
200214
}
201215

202216
const docs = productResources[values[1]] ?? [];

0 commit comments

Comments
 (0)