Skip to content

Commit

Permalink
Update server.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shoushou1106 committed Dec 21, 2024
1 parent 94f0b75 commit 5ed5bd8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,23 @@ router.post('/', async (request, env: Env) => {
);
}

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',
}),
}
);
return new Response();

// Stream the AI response and update the message
await streamFromAI(interaction, userPrompt, env);

return new Response();
}
default:
return new JsonResponse({ error: 'Unknown Type' }, { status: 400 });
Expand Down Expand Up @@ -152,18 +165,7 @@ async function streamFromAI(interaction: APIInteraction, prompt: string, env: En
// }
// return "No response";

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 });
Expand Down

0 comments on commit 5ed5bd8

Please sign in to comment.