Fix postSystemMessage() text not being chunked
This would cause errors if the system message was over 2000 characters in length.cshd
parent
d8e6222bae
commit
1210b2acaa
|
@ -89,10 +89,11 @@ class Thread {
|
||||||
try {
|
try {
|
||||||
let firstMessage;
|
let firstMessage;
|
||||||
|
|
||||||
if (typeof content === "string") {
|
const textContent = typeof content === "string" ? content : content.content;
|
||||||
// Content is a string, chunk it and send it as individual messages.
|
if (textContent) {
|
||||||
|
// Text content is included, chunk it and send it as individual messages.
|
||||||
// Files (attachments) are only sent with the last message.
|
// Files (attachments) are only sent with the last message.
|
||||||
const chunks = utils.chunkMessageLines(content);
|
const chunks = utils.chunkMessageLines(textContent);
|
||||||
for (const [i, chunk] of chunks.entries()) {
|
for (const [i, chunk] of chunks.entries()) {
|
||||||
// Only send embeds, files, etc. with the last message
|
// Only send embeds, files, etc. with the last message
|
||||||
const msg = (i === chunks.length - 1)
|
const msg = (i === chunks.length - 1)
|
||||||
|
@ -102,7 +103,7 @@ class Thread {
|
||||||
firstMessage = firstMessage || msg;
|
firstMessage = firstMessage || msg;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Content is a full message content object, send it as-is with the files (if any)
|
// No text content, send as one message
|
||||||
firstMessage = await bot.createMessage(this.channel_id, content, file);
|
firstMessage = await bot.createMessage(this.channel_id, content, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue