From 94f0b75cadff6b3eeacbff14c4a6a17afed88e2b Mon Sep 17 00:00:00 2001 From: shoushou Date: Sat, 21 Dec 2024 12:15:34 -0800 Subject: [PATCH] fix: Wrong react --- src/server.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/server.ts b/src/server.ts index cf8918b..bd08b1e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -92,8 +92,7 @@ router.post('/', async (request, env: Env) => { "Content-Type": "application/json", }, body: JSON.stringify({ - type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, - content: "*Waiting...*" + type: InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE }), } ); @@ -153,7 +152,20 @@ async function streamFromAI(interaction: APIInteraction, prompt: string, env: En // } // return "No response"; - try { + await fetch( + `https://discord.com/api/v10/webhooks/${env.DISCORD_APPLICATION_ID}/${interaction.token}/messages/@original`, + { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + content: 'Hi', + }), + } + ); + + /*try { const together = new Together({ apiKey: env.TOGETHER_API_KEY }); const stream = await together.chat.completions.create({ @@ -209,7 +221,6 @@ async function streamFromAI(interaction: APIInteraction, prompt: string, env: En }), } ); - } - return; + }*/ } export default server;