Skip to content

Commit

Permalink
Update messageCreate.js
Browse files Browse the repository at this point in the history
  • Loading branch information
iTzArshia committed Sep 28, 2023
1 parent bff93fb commit 581edd0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ module.exports = async (client, message) => {

}).then(async (response) => {


let fullAnswer = "";
let answer = "";
let newMessage = message;
Expand All @@ -312,6 +311,8 @@ module.exports = async (client, message) => {

if (part.choices[0]?.finish_reason === 'stop') {

await message.channel.sendTyping();

const newDataArray = [
{
"role": "user",
Expand Down Expand Up @@ -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 || '';
Expand Down

0 comments on commit 581edd0

Please sign in to comment.