@@ -70,34 +70,38 @@ client.on("messageCreate", async (message) => {
70
70
} ) ;
71
71
console . log ( `[log]: responded to version command in version ${ version } ` ) ;
72
72
}
73
- if ( message . channel . id === ASKAI_CHANNEL && message . content . startsWith ( '!askai' ) || message . channel . id === ASKAI_CHANNEL && message . content . startsWith ( '!ask' ) ) {
74
- let question = message . content . startsWith ( '!askai' ) ? message . content . slice ( 6 ) : message . content . slice ( 4 )
75
- let aiMessageLoading = await message . channel . send ( {
76
- embeds : [
77
- sendEmbedMessage ( "**🤖 Beep Boop Boop Beep:** " + `<a:load:1210497921158619136> thinking...` ) ,
78
- ] ,
79
- } ) ;
80
- await context . query ( {
81
- botId : CONTEXT_ID ,
82
- query : question ,
83
- onComplete : async ( query ) => {
84
- // console.log(query.output.toString())
85
- await message . channel . messages . fetch ( aiMessageLoading . id ) . then ( ( msg ) =>
86
- msg . edit ( {
87
- content : `Hey <@${ message . author . id } > 👇` ,
88
- embeds : [
89
- sendEmbedMessage ( `**Response:**\n${ query . output . toString ( ) } ` ) ,
90
- ] ,
91
-
92
- } )
93
- ) ;
94
-
95
- } ,
96
- onError : ( error ) => {
97
- console . error ( error ) ;
98
- } ,
99
- } ) ;
73
+ // respond to ask command
74
+ if ( ( message . content . startsWith ( '!askai' ) || message . content . startsWith ( '!ask' ) ) ) {
75
+ let question = message . content . startsWith ( '!askai' ) ? message . content . slice ( 6 ) : message . content . slice ( 4 ) ;
76
+ if ( message . channel . id === ASKAI_CHANNEL ) {
77
+ let aiMessageLoading = await message . channel . send ( {
78
+ embeds : [
79
+ sendEmbedMessage ( "**🤖 Beep Boop Boop Beep:** " + `<a:load:1210497921158619136> thinking...` ) ,
80
+ ] ,
81
+ } ) ;
100
82
83
+ try {
84
+ const query = await context . query ( {
85
+ botId : CONTEXT_ID ,
86
+ query : question
87
+ } ) ;
88
+
89
+ const msg = await message . channel . messages . fetch ( aiMessageLoading . id ) ;
90
+ await msg . edit ( {
91
+ content : `Hey <@${ message . author . id } > 👇` ,
92
+ embeds : [
93
+ sendEmbedMessage ( `**Response:**\n${ query . output . toString ( ) } ` ) ,
94
+ ] ,
95
+ } ) ;
96
+ } catch ( error ) {
97
+ console . error ( error ) ;
98
+ }
99
+ } else {
100
+ message . reply ( {
101
+ content : `Hey <@${ message . author . id } > 👇` ,
102
+ embeds : [ sendEmbedMessage ( `You can ask me all things thirdweb in the <#${ ASKAI_CHANNEL } > channel. Just type your question after the command \`!askai\` or \`!ask\` to get started.` ) ] ,
103
+ } ) ;
104
+ }
101
105
}
102
106
// respond to user if the bot mentioned specifically not with everyone
103
107
if ( message . mentions . has ( client . user ) && ! message . mentions . everyone ) {
0 commit comments