@@ -86,7 +86,14 @@ export function provideCommands(): CommandDescriptor[] {
86
86
. setDescription (
87
87
'Send a link to the "Don\'t ask to ask" website'
88
88
) ,
89
- handler : handleJustAskCommand ,
89
+ handler : handleJustAskSlashCommand ,
90
+ permission : CommandPermission . Public ,
91
+ } ,
92
+ {
93
+ builder : new Builders . ContextMenuCommandBuilder ( )
94
+ . setName ( "Just Ask" )
95
+ . setType ( Discord . ApplicationCommandType . Message ) ,
96
+ handler : handleJustAskContextMenuCommand ,
90
97
permission : CommandPermission . Public ,
91
98
} ,
92
99
{
@@ -204,11 +211,14 @@ export async function handleWhoSaidCommand(
204
211
}
205
212
}
206
213
207
- export async function handleJustAskCommand (
208
- interaction : Discord . ChatInputCommandInteraction
214
+ export async function sendJustAsk (
215
+ interaction : Discord . CommandInteraction ,
216
+ sender : (
217
+ ...args : Parameters < typeof Discord . Message . prototype . reply >
218
+ ) => Promise < unknown > // to allow optional chaining (?.)
209
219
) : Promise < void > {
210
220
try {
211
- await interaction . channel ?. send ( "https://dontasktoask.com/" ) ;
221
+ await sender ( "https://dontasktoask.com/" ) ;
212
222
await interaction . editReply ( utils . CheckMarkEmoji + "Sent" ) ;
213
223
logger . info ( { member : interaction . member } , "Used don't ask to ask" ) ;
214
224
} catch ( e ) {
@@ -217,6 +227,28 @@ export async function handleJustAskCommand(
217
227
}
218
228
}
219
229
230
+ export async function handleJustAskSlashCommand (
231
+ interaction : Discord . ChatInputCommandInteraction
232
+ ) : Promise < void > {
233
+ if ( interaction . channel ) {
234
+ await sendJustAsk (
235
+ interaction ,
236
+ async ( ...args ) => await interaction . channel ?. send ( ...args )
237
+ ) ;
238
+ }
239
+ }
240
+
241
+ export async function handleJustAskContextMenuCommand (
242
+ interaction : Discord . ContextMenuCommandInteraction
243
+ ) : Promise < void > {
244
+ if ( interaction . isMessageContextMenuCommand ( ) ) {
245
+ await sendJustAsk (
246
+ interaction ,
247
+ async ( ...args ) => await interaction . targetMessage ?. reply ( ...args )
248
+ ) ;
249
+ }
250
+ }
251
+
220
252
export async function handleMigrateMembersWithRole (
221
253
interaction : Discord . ChatInputCommandInteraction
222
254
) : Promise < void > {
0 commit comments