@@ -7,22 +7,25 @@ import {
77import { Command } from "../index.js" ;
88import { EmbedList , fetchBingus , fetchBingusData } from "../util.js" ;
99
10- const textCleanRegex = / [ ^ a - z ] / gi
10+ const textCleanRegex = / [ ^ a - z ] / gi;
1111
1212async function getFaqConfig ( ) {
13- return ( await fetchBingusData ( ) ) . faqs . flatMap ( ( x ) =>
14- x . keywords . filter ( ( x ) => x . length > 0 && x . length <= 100 ) ,
15- ) . map ( ( x ) => ( {
16- clean : x . toLowerCase ( ) . replaceAll ( textCleanRegex , "" ) ,
17- orig : x
18- } ) ) ;
13+ return ( await fetchBingusData ( ) ) . faqs
14+ . flatMap ( ( x ) => x . keywords . filter ( ( x ) => x . length > 0 && x . length <= 100 ) )
15+ . map ( ( x ) => ( {
16+ clean : x . toLowerCase ( ) . replaceAll ( textCleanRegex , "" ) ,
17+ orig : x ,
18+ } ) ) ;
1919}
2020
2121let faqConfig = await getFaqConfig ( ) ;
2222
23- setInterval ( async ( ) => {
24- faqConfig = await getFaqConfig ( ) ;
25- } , 60 * 60 * 1000 ) ; // Do it every hour
23+ setInterval (
24+ async ( ) => {
25+ faqConfig = await getFaqConfig ( ) ;
26+ } ,
27+ 60 * 60 * 1000 ,
28+ ) ; // Do it every hour
2629
2730export const askCommand : Command = {
2831 builder : new SlashCommandBuilder ( )
@@ -56,7 +59,6 @@ export const askCommand: Command = {
5659 ) ,
5760 ) ,
5861 async run ( interaction ) {
59- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6062 const query = interaction . options . getString ( "query" ) ! ;
6163 const customOption = interaction . options . getString ( "custom" ) ;
6264 const first = customOption === "FIRST" ;
@@ -101,16 +103,24 @@ export const askCommand: Command = {
101103 ) ,
102104 ) ;
103105
104- await embedList . sendChatInput ( interaction , customOption === "KINDA_VISIBLE" ) ;
106+ await embedList . sendChatInput (
107+ interaction ,
108+ customOption === "KINDA_VISIBLE" ,
109+ ) ;
105110 } catch ( error ) {
106111 console . error ( error ) ;
107112 interaction . editReply ( "An error occurred while fetching results." ) ;
108113 }
109114 } ,
110115 async autocomplete ( interaction ) {
111- const focusedValue = interaction . options . getFocused ( ) . toLowerCase ( ) . replaceAll ( textCleanRegex , "" ) ;
116+ const focusedValue = interaction . options
117+ . getFocused ( )
118+ . toLowerCase ( )
119+ . replaceAll ( textCleanRegex , "" ) ;
112120 const filtered = faqConfig . filter ( ( x ) => x . clean . includes ( focusedValue ) ) ;
113121 filtered . length = Math . min ( filtered . length , 25 ) ;
114- await interaction . respond ( filtered . map ( ( x ) => ( { name : x . orig , value : x . orig } ) ) ) ;
122+ await interaction . respond (
123+ filtered . map ( ( x ) => ( { name : x . orig , value : x . orig } ) ) ,
124+ ) ;
115125 } ,
116126} ;
0 commit comments