@@ -43,7 +43,18 @@ const THREAD_CHECK_CADENCE = 12 * HOUR // 12 * HOUR
43
43
* A helper to request follow-up action on a thread based on the id of the user
44
44
* who will follow up and the initial requester of follow-up action.
45
45
*/
46
- function requestFollowUpAction (
46
+
47
+ const getNickname = async ( interaction : ButtonInteraction ) : Promise < string > => {
48
+ const { user, guild } = interaction
49
+
50
+ if ( ! guild ) {
51
+ return user . username
52
+ }
53
+ const member = await guild . members . fetch ( user . id )
54
+ return member . nickname || user . username
55
+ }
56
+
57
+ async function requestFollowUpAction (
47
58
thread : ThreadChannel < boolean > ,
48
59
interaction : ButtonInteraction ,
49
60
followUpRequester : GuildMember | APIInteractionGuildMember | null ,
@@ -55,6 +66,8 @@ function requestFollowUpAction(
55
66
const currentTime = Date . now ( )
56
67
const followUpDeadline = Math . floor ( ( currentTime + 24 * HOUR ) / 1000 )
57
68
69
+ const nickname = await getNickname ( interaction )
70
+
58
71
if ( followUpUserId === requestingUserId ) {
59
72
// If the user designates themselves, delete the initial bot message to remove the dropdown
60
73
interaction . deleteReply ( ) . catch ( ( error ) => {
@@ -65,7 +78,7 @@ function requestFollowUpAction(
65
78
. followUp ( {
66
79
content : `Thanks ${ userMention (
67
80
requestingUserId ,
68
- ) } , please ${ requestedAction } this thread or it will be archived in <t:${ followUpDeadline } :F> (<t:${ followUpDeadline } :R> ❤️`,
81
+ ) } , please ${ requestedAction } this thread or it will be archived in <t:${ followUpDeadline } :F> (<t:${ followUpDeadline } :R> ❤️) `,
69
82
ephemeral : true ,
70
83
} )
71
84
. catch ( ( error ) => {
@@ -77,7 +90,7 @@ function requestFollowUpAction(
77
90
. send ( {
78
91
content : `${ userMention (
79
92
followUpUserId ,
80
- ) } please ${ requestedAction } this thread or it will be archived in <t:${ followUpDeadline } :F> (<t:${ followUpDeadline } :R> ❤️ `,
93
+ ) } please ${ requestedAction } this thread or it will be archived in <t:${ followUpDeadline } :F> (<t:${ followUpDeadline } :R>) - ❤️ Love, ${ nickname } `,
81
94
} )
82
95
. catch ( ( error ) => {
83
96
robot ?. logger . info ( "Failed to send message in thread:" , error )
@@ -89,16 +102,6 @@ function requestFollowUpAction(
89
102
}
90
103
}
91
104
92
- const getNickname = async ( interaction : ButtonInteraction ) : Promise < string > => {
93
- const { user, guild } = interaction
94
-
95
- if ( ! guild ) {
96
- return user . username
97
- }
98
- const member = await guild . members . fetch ( user . id )
99
- return member . nickname || user . username
100
- }
101
-
102
105
const threadActions : {
103
106
[ action : string ] : Pick < APIButtonComponentWithCustomId , "label" > & {
104
107
handler : ( thread : ThreadChannel , interaction : ButtonInteraction ) => void
@@ -130,7 +133,6 @@ const threadActions: {
130
133
extendAutoArchive : true ,
131
134
handler : async ( thread , interaction ) => {
132
135
const posterSelectId = `task-poster-select-${ interaction . id } `
133
- const nickname = await getNickname ( interaction )
134
136
await interaction . reply ( {
135
137
ephemeral : true ,
136
138
content :
@@ -167,10 +169,7 @@ const threadActions: {
167
169
userIdToTag ,
168
170
)
169
171
170
- await interaction . message . edit ( {
171
- content : `${ interaction . message . content } \n\n🔲 **Task capture requested** by ${ nickname } ` ,
172
- components : [ ] ,
173
- } )
172
+ await interaction . message . delete ( )
174
173
} ,
175
174
} ,
176
175
"check-thread-archiving-status-button" : {
@@ -179,7 +178,6 @@ const threadActions: {
179
178
extendAutoArchive : false ,
180
179
handler : async ( thread , interaction ) => {
181
180
const posterSelectId = `status-poster-select-${ interaction . id } `
182
- const nickname = await getNickname ( interaction )
183
181
await interaction . reply ( {
184
182
ephemeral : true ,
185
183
content :
@@ -217,10 +215,7 @@ const threadActions: {
217
215
userIdToTag ,
218
216
)
219
217
220
- await interaction . message . edit ( {
221
- content : `${ interaction . message . content } \n\n✍️ **Status requested** by ${ nickname } ` ,
222
- components : [ ] ,
223
- } )
218
+ await interaction . message . delete ( )
224
219
} ,
225
220
} ,
226
221
"check-thread-archiving-pending-decision-button" : {
@@ -229,7 +224,6 @@ const threadActions: {
229
224
extendAutoArchive : true ,
230
225
handler : async ( thread , interaction ) => {
231
226
const posterSelectId = `decision-poster-select-${ interaction . id } `
232
- const nickname = await getNickname ( interaction )
233
227
await interaction . reply ( {
234
228
ephemeral : true ,
235
229
content :
@@ -267,10 +261,7 @@ const threadActions: {
267
261
userIdToTag ,
268
262
)
269
263
270
- await interaction . message . edit ( {
271
- content : `${ interaction . message . content } \n\n🫵 **Decision requested** by ${ nickname } ` ,
272
- components : [ ] ,
273
- } )
264
+ await interaction . message . delete ( )
274
265
} ,
275
266
} ,
276
267
}
0 commit comments