diff --git a/events/messageCreate.js b/events/messageCreate.js index f39dac8..310a2eb 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -303,7 +303,6 @@ module.exports = async (client, message) => { }).then(async (response) => { - let fullAnswer = ""; let answer = ""; let newMessage = message; @@ -312,6 +311,8 @@ module.exports = async (client, message) => { if (part.choices[0]?.finish_reason === 'stop') { + await message.channel.sendTyping(); + const newDataArray = [ { "role": "user", @@ -347,15 +348,29 @@ module.exports = async (client, message) => { } else { - if (answer.includes('\n\n') && answer.length <= 2000) { + if (answer.includes('\n\n')) { await message.channel.sendTyping(); - newMessage = await newMessage.reply({ content: answer }); - answer = ""; + if (answer.length <= 2000) { + + newMessage = await newMessage.reply({ content: answer }); + + } else { + const attachment = new Discord.AttachmentBuilder( + Buffer.from(answer, 'utf-8'), + { name: 'response.txt' } + ); + + await newMessage.reply({ files: [attachment] }); + + }; + + answer = ""; await func.delay(5000); + }; answer += part.choices[0]?.delta?.content || '';