Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add links to some resources in walkthrough #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
78 changes: 69 additions & 9 deletions src/commands/util/walkthrough.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,64 @@ import {
Colors,
type PublicThreadChannel,
type GuildTextBasedChannel,
FetchMessageOptions,
ButtonBuilder,
ButtonStyle,
ContainerBuilder,
MessageFlags,
SectionBuilder,
SeparatorBuilder,
TextDisplayBuilder,
type MessageCreateOptions,
type InteractionReplyOptions,
} from "discord.js";

const resourcesMessage = {
flags: MessageFlags.IsComponentsV2,

components: [
new ContainerBuilder().addSectionComponents([
new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder({ content: "Where to find logs" }),
)
.setButtonAccessory(
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel("Docs")
.setURL("https://coder.com/docs/admin/monitoring/logs"),
),

new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder({
content: "Troubleshooting templates",
}),
)
.setButtonAccessory(
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel("Docs")
.setURL("https://coder.com/docs/admin/templates/troubleshooting"),
),

new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder({
content: "Troubleshooting networking",
}),
)
.setButtonAccessory(
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel("Docs")
.setURL("https://coder.com/docs/admin/networking/troubleshooting"),
),
]),

new SeparatorBuilder(),
],
};

export function generateQuestion(
question: string,
component: StringSelectMenuBuilder,
Expand Down Expand Up @@ -46,13 +101,9 @@ export async function doWalkthrough(
threadChannel.setAppliedTags(appliedTags);
}

// Generate the message with the action row
const message = generateQuestion(
"What are you creating this issue for?",
issueCategorySelector,
);

// Send the resources message (or reply to the user if they're running the command)
if (interaction) {
// TODO: also check for components V2, but wait until revamp
// If the bot has sent a message that contains an embed in the first 30 messages, then we assume it's the walkthrough message
const firstMessage = await threadChannel.fetchStarterMessage();
const walkthroughMessage = await threadChannel.messages
Expand All @@ -73,11 +124,20 @@ export async function doWalkthrough(
ephemeral: true,
});
} else {
return interaction.reply(message);
// TODO: fix the fact that it looks weird when the resources message is sent as a reply
await interaction.reply(resourcesMessage as InteractionReplyOptions);
}
} else {
return channel.send(message);
await channel.send(resourcesMessage as MessageCreateOptions);
}

// Generate the walkthrough message asking the user what they're creating this issue for
const message = generateQuestion(
"What are you creating this issue for?",
issueCategorySelector,
);

return channel.send(message);
}
}

Expand Down