Skip to content

Commit

Permalink
fix: queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Googlefan committed Jun 16, 2024
1 parent beabfd7 commit e2f0338
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/queue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseGuildTextChannel, Collection } from "discord.js";
import { BaseGuildTextChannel, Collection, MessageEditOptions } from "discord.js";
import { Chat, models } from "./chat";
import { client } from ".";

Expand Down Expand Up @@ -66,7 +66,18 @@ setInterval(() => {
lastTokens = tokens;
}
}
await msg?.edit(contents);
const payload: MessageEditOptions = {};
if (contents.length < 2000) {
payload["content"] = contents;
} else {
payload["files"] = [
{
attachment: Buffer.from(contents),
name: "output.txt",
},
];
}
await msg?.edit(payload);
addHistory(channelId, chat);
addHistory(channelId, {
text: contents,
Expand All @@ -77,7 +88,7 @@ setInterval(() => {
if (msg) {
try {
await msg.edit("Failed to generate message");
} catch {}
} catch { }
}
}
chatQueue.set(channelId, {
Expand Down

0 comments on commit e2f0338

Please sign in to comment.