@@ -13,9 +13,64 @@ import {
13
13
Colors ,
14
14
type PublicThreadChannel ,
15
15
type GuildTextBasedChannel ,
16
- FetchMessageOptions ,
16
+ ButtonBuilder ,
17
+ ButtonStyle ,
18
+ ContainerBuilder ,
19
+ MessageFlags ,
20
+ SectionBuilder ,
21
+ SeparatorBuilder ,
22
+ TextDisplayBuilder ,
23
+ type MessageCreateOptions ,
24
+ type InteractionReplyOptions ,
17
25
} from "discord.js" ;
18
26
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
+
19
74
export function generateQuestion (
20
75
question : string ,
21
76
component : StringSelectMenuBuilder ,
@@ -46,13 +101,9 @@ export async function doWalkthrough(
46
101
threadChannel . setAppliedTags ( appliedTags ) ;
47
102
}
48
103
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)
55
105
if ( interaction ) {
106
+ // TODO: also check for components V2, but wait until revamp
56
107
// If the bot has sent a message that contains an embed in the first 30 messages, then we assume it's the walkthrough message
57
108
const firstMessage = await threadChannel . fetchStarterMessage ( ) ;
58
109
const walkthroughMessage = await threadChannel . messages
@@ -73,11 +124,20 @@ export async function doWalkthrough(
73
124
ephemeral : true ,
74
125
} ) ;
75
126
} 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 ) ;
77
129
}
78
130
} else {
79
- return channel . send ( message ) ;
131
+ await channel . send ( resourcesMessage as MessageCreateOptions ) ;
80
132
}
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 ) ;
81
141
}
82
142
}
83
143
0 commit comments