generated from nhcarrigan/template
feat: okay i hate the multiple messages, lets chunk instead
Node.js CI / Lint and Test (push) Successful in 36s
Node.js CI / Lint and Test (push) Successful in 36s
This commit is contained in:
@@ -19,9 +19,17 @@ export const sendAiResponse = async(
|
|||||||
send: GuildTextBasedChannel["send"] | DMChannel["send"] | Message["reply"],
|
send: GuildTextBasedChannel["send"] | DMChannel["send"] | Message["reply"],
|
||||||
type: GuildTextBasedChannel["sendTyping"],
|
type: GuildTextBasedChannel["sendTyping"],
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
for (const line of content) {
|
const joined = content.join("\n\n");
|
||||||
await send(line);
|
if (joined.length < 4000) {
|
||||||
await type();
|
await send(joined);
|
||||||
await sleep(2500);
|
return;
|
||||||
|
}
|
||||||
|
const chunks = joined.match(/[\S\s]{1,4000}/g);
|
||||||
|
if (chunks) {
|
||||||
|
for (const chunk of chunks) {
|
||||||
|
await send(chunk);
|
||||||
|
await type();
|
||||||
|
await sleep(2500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user