11import { config } from "@lib/config.js" ;
22
33import { isHelpPost as isHelpThread } from "@lib/discord/channels.js" ;
4+ import { getCommandMention } from "@lib/discord/commands.js" ;
45import issueCategorySelector from "@components/issueCategorySelector.js" ;
56
67import {
78 type ChatInputCommandInteraction ,
9+ type Client ,
810 SlashCommandBuilder ,
911 ActionRowBuilder ,
1012 type StringSelectMenuBuilder ,
@@ -24,52 +26,63 @@ import {
2426 type InteractionReplyOptions ,
2527} from "discord.js" ;
2628
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- ) ,
29+ async function buildResourcesMessage ( client : Client ) {
30+ return {
31+ flags : MessageFlags . IsComponentsV2 ,
5532
56- new SectionBuilder ( )
33+ components : [
34+ new ContainerBuilder ( )
35+ . addSectionComponents ( [
36+ new SectionBuilder ( )
37+ . addTextDisplayComponents (
38+ new TextDisplayBuilder ( { content : "Where to find logs" } ) ,
39+ )
40+ . setButtonAccessory (
41+ new ButtonBuilder ( )
42+ . setStyle ( ButtonStyle . Link )
43+ . setLabel ( "Docs" )
44+ . setURL ( "https://coder.com/docs/admin/monitoring/logs" ) ,
45+ ) ,
46+
47+ new SectionBuilder ( )
48+ . addTextDisplayComponents (
49+ new TextDisplayBuilder ( {
50+ content : "Troubleshooting templates" ,
51+ } ) ,
52+ )
53+ . setButtonAccessory (
54+ new ButtonBuilder ( )
55+ . setStyle ( ButtonStyle . Link )
56+ . setLabel ( "Docs" )
57+ . setURL (
58+ "https://coder.com/docs/admin/templates/troubleshooting" ,
59+ ) ,
60+ ) ,
61+
62+ new SectionBuilder ( )
63+ . addTextDisplayComponents (
64+ new TextDisplayBuilder ( {
65+ content : "Troubleshooting networking" ,
66+ } ) ,
67+ )
68+ . setButtonAccessory (
69+ new ButtonBuilder ( )
70+ . setStyle ( ButtonStyle . Link )
71+ . setLabel ( "Docs" )
72+ . setURL (
73+ "https://coder.com/docs/admin/networking/troubleshooting" ,
74+ ) ,
75+ ) ,
76+ ] )
77+ . addSeparatorComponents ( new SeparatorBuilder ( ) )
5778 . addTextDisplayComponents (
5879 new TextDisplayBuilder ( {
59- content : "Troubleshooting networking" ,
80+ content : `When your issue is resolved, use ${ await getCommandMention ( client , "close" ) } to close this post. Use ${ await getCommandMention ( client , "reopen" ) } to reopen it if needed.` ,
6081 } ) ,
61- )
62- . setButtonAccessory (
63- new ButtonBuilder ( )
64- . setStyle ( ButtonStyle . Link )
65- . setLabel ( "Docs" )
66- . setURL ( "https://coder.com/docs/admin/networking/troubleshooting" ) ,
6782 ) ,
68- ] ) ,
69-
70- new SeparatorBuilder ( ) ,
71- ] ,
72- } ;
83+ ] ,
84+ } ;
85+ }
7386
7487export function generateQuestion (
7588 question : string ,
@@ -94,6 +107,8 @@ export async function doWalkthrough(
94107 if ( await isHelpThread ( channel ) ) {
95108 const threadChannel = channel as PublicThreadChannel ; // necessary type cast, isHelpThread does the check already
96109
110+ const resourcesMessage = await buildResourcesMessage ( channel . client ) ;
111+
97112 // Check for tags in the forum post
98113 const appliedTags = threadChannel . appliedTags ?? [ ] ;
99114 if ( ! appliedTags . includes ( config . helpChannel . openedTag ) ) {
0 commit comments