Skip to content

Commit 851a0b1

Browse files
authored
feat: add links to some resources in walkthrough (#19)
* feat: add links to some resources in walkthrough * fix: fix lockfile * chore: format & lint
1 parent 8a167c1 commit 851a0b1

File tree

2 files changed

+69
-9
lines changed

2 files changed

+69
-9
lines changed

bun.lockb

16 Bytes
Binary file not shown.

src/commands/util/walkthrough.ts

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,64 @@ import {
1313
Colors,
1414
type PublicThreadChannel,
1515
type GuildTextBasedChannel,
16-
FetchMessageOptions,
16+
ButtonBuilder,
17+
ButtonStyle,
18+
ContainerBuilder,
19+
MessageFlags,
20+
SectionBuilder,
21+
SeparatorBuilder,
22+
TextDisplayBuilder,
23+
type MessageCreateOptions,
24+
type InteractionReplyOptions,
1725
} from "discord.js";
1826

27+
const resourcesMessage = {
28+
flags: MessageFlags.IsComponentsV2,
29+
30+
components: [
31+
new ContainerBuilder().addSectionComponents([
32+
new SectionBuilder()
33+
.addTextDisplayComponents(
34+
new TextDisplayBuilder({ content: "Where to find logs" }),
35+
)
36+
.setButtonAccessory(
37+
new ButtonBuilder()
38+
.setStyle(ButtonStyle.Link)
39+
.setLabel("Docs")
40+
.setURL("https://coder.com/docs/admin/monitoring/logs"),
41+
),
42+
43+
new SectionBuilder()
44+
.addTextDisplayComponents(
45+
new TextDisplayBuilder({
46+
content: "Troubleshooting templates",
47+
}),
48+
)
49+
.setButtonAccessory(
50+
new ButtonBuilder()
51+
.setStyle(ButtonStyle.Link)
52+
.setLabel("Docs")
53+
.setURL("https://coder.com/docs/admin/templates/troubleshooting"),
54+
),
55+
56+
new SectionBuilder()
57+
.addTextDisplayComponents(
58+
new TextDisplayBuilder({
59+
content: "Troubleshooting networking",
60+
}),
61+
)
62+
.setButtonAccessory(
63+
new ButtonBuilder()
64+
.setStyle(ButtonStyle.Link)
65+
.setLabel("Docs")
66+
.setURL("https://coder.com/docs/admin/networking/troubleshooting"),
67+
),
68+
]),
69+
70+
new SeparatorBuilder(),
71+
],
72+
};
73+
1974
export function generateQuestion(
2075
question: string,
2176
component: StringSelectMenuBuilder,
@@ -46,13 +101,9 @@ export async function doWalkthrough(
46101
threadChannel.setAppliedTags(appliedTags);
47102
}
48103

49-
// Generate the message with the action row
50-
const message = generateQuestion(
51-
"What are you creating this issue for?",
52-
issueCategorySelector,
53-
);
54-
104+
// Send the resources message (or reply to the user if they're running the command)
55105
if (interaction) {
106+
// TODO: also check for components V2, but wait until revamp
56107
// If the bot has sent a message that contains an embed in the first 30 messages, then we assume it's the walkthrough message
57108
const firstMessage = await threadChannel.fetchStarterMessage();
58109
const walkthroughMessage = await threadChannel.messages
@@ -73,11 +124,20 @@ export async function doWalkthrough(
73124
ephemeral: true,
74125
});
75126
} else {
76-
return interaction.reply(message);
127+
// TODO: fix the fact that it looks weird when the resources message is sent as a reply
128+
await interaction.reply(resourcesMessage as InteractionReplyOptions);
77129
}
78130
} else {
79-
return channel.send(message);
131+
await channel.send(resourcesMessage as MessageCreateOptions);
80132
}
133+
134+
// Generate the walkthrough message asking the user what they're creating this issue for
135+
const message = generateQuestion(
136+
"What are you creating this issue for?",
137+
issueCategorySelector,
138+
);
139+
140+
return channel.send(message);
81141
}
82142
}
83143

0 commit comments

Comments
 (0)