@@ -7,15 +7,7 @@ import { ChatEmbed } from '@/bot/embeds/chatEmbed';
7
7
import { SystemEmbed } from '@/bot/embeds/systemEmbed' ;
8
8
9
9
export class ChatCommand extends Command {
10
- constructor ( ) {
11
- /**
12
- * Call the parent constructor
13
- */
14
- super ( ) ;
15
-
16
- /**
17
- * Set command data for Discord API
18
- */
10
+ public configure ( ) : void {
19
11
this . setName ( 'chat' ) ;
20
12
this . setDescription ( 'Chat with the bot' ) ;
21
13
this . addStringOption ( ( option ) => option
@@ -79,33 +71,33 @@ export class ChatCommand extends Command {
79
71
chatHistory . push ( currentQuestion ) ;
80
72
81
73
/**
82
- * Embeds array to store the embeds
83
- */
84
- const embeds : EmbedBuilder [ ] = [ ] ;
85
-
86
- /**
87
- * Create the question embed and add it to the embeds array
74
+ * Embeds array with initial embed for the question
88
75
*/
89
- const questionEmbed = new ChatEmbed ( client , interaction , EmbedAuthor . User , question as string ) ;
90
- embeds . push ( questionEmbed ) ;
76
+ const embeds : EmbedBuilder [ ] = [
77
+ new ChatEmbed ( client , interaction , EmbedAuthor . User , question as string ) ,
78
+ ] ;
91
79
92
80
/**
93
81
* Get the answer from the AI
94
82
*/
95
83
await ai ?. chatCompletion ( chatHistory )
96
84
. then ( ( response ) => {
97
- const responseEmbed = new ChatEmbed ( client , interaction , EmbedAuthor . Bot , response . content ) ; // Create a new text embed with the response
98
- embeds . push ( responseEmbed ) ; // Add the response embed to the embeds array
85
+ /**
86
+ * Add the response to the embeds array
87
+ */
88
+ embeds . push ( new ChatEmbed ( client , interaction , EmbedAuthor . Bot , response . content ) ) ;
99
89
} ) // Get the content from the response
100
90
. catch ( ( error : Error ) => {
101
- const errorEmbed = new SystemEmbed (
91
+ /**
92
+ * Add the error to the embeds array
93
+ */
94
+ embeds . push ( new SystemEmbed (
102
95
client ,
103
96
interaction ,
104
97
EmbedAuthor . Bot ,
105
98
EmbedType . Error ,
106
99
error . message ,
107
- ) ; // Create a new error embed with the error message
108
- embeds . push ( errorEmbed ) ; // Add the error embed to the embeds array
100
+ ) ) ;
109
101
} ) ;
110
102
111
103
/**
0 commit comments