@@ -22,7 +22,7 @@ client.on('interactionCreate', async interaction => {
22
22
if ( commandName === 'se' ) {
23
23
for ( i = 0 ; i < 10 ; i ++ ) {
24
24
try {
25
- const res = await axios . get ( process . env . URL , { timeout : 1000 } ) ;
25
+ const res = await axios . get ( process . env . API_URL + '/v2/random' , { timeout : 1000 } ) ;
26
26
const url = res . data ;
27
27
console . log ( 'Get url: ' + url ) ;
28
28
await interaction . reply ( url ) ;
@@ -34,7 +34,7 @@ client.on('interactionCreate', async interaction => {
34
34
} else if ( commandName === 'mo' ) {
35
35
for ( i = 0 ; i < 10 ; i ++ ) {
36
36
try {
37
- const res = await axios . get ( process . env . MOYU_URL , { timeout : 1000 } ) ;
37
+ const res = await axios . get ( process . env . API_URL + '/moyu' , { timeout : 1000 } ) ;
38
38
const text = res . data ;
39
39
await interaction . reply ( text ) ;
40
40
return
@@ -60,5 +60,32 @@ client.on('interactionCreate', async interaction => {
60
60
}
61
61
} ) ;
62
62
63
+
64
+ client . on ( 'messageCreate' , async message => {
65
+ if ( message . content === 'ping' ) {
66
+ message . reply ( 'Pong!' ) ;
67
+ }
68
+ const prefix = "/" ;
69
+ if (
70
+ ! message . content . startsWith ( prefix )
71
+ || message . author . bot
72
+ || message . content . length > 200
73
+ ) return ;
74
+ try {
75
+ const res = await axios . post (
76
+ process . env . API_URL + '/chatgpt' ,
77
+ {
78
+ token : process . env . API_TOKEN ,
79
+ text : message . content ,
80
+ chat_id : "discord"
81
+ } ,
82
+ { timeout : 10000 }
83
+ ) ;
84
+ const text = res . data ;
85
+ await message . reply ( text ) ;
86
+ } catch ( error ) {
87
+ console . error ( error ) ;
88
+ }
89
+ } )
63
90
// Login to Discord with your client's token
64
91
client . login ( process . env . DISCORD_TOKEN ) ;
0 commit comments