Remove faulty message chunking logic in user DMs

The logic could cause things like code blocks get cut in the middle
without being handled gracefully. With this change, messages sent
to the user can take, at most, 1 message. This does not affect
messages in the thread channel.
cshd
Dragory 2020-10-21 21:00:45 +03:00
parent 192fec6952
commit 42f6e79df8
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 1 additions and 23 deletions

View File

@ -73,29 +73,7 @@ class Thread {
throw new Error("Could not open DMs with the user. They may have blocked the bot or set their privacy settings higher.");
}
let firstMessage;
if (typeof content === "string") {
// Content is a string, chunk it and send it as individual messages.
// Files (attachments) are only sent with the last message.
const chunks = utils.chunk(content, 2000);
for (const [i, chunk] of chunks.entries()) {
let msg;
if (i === chunks.length - 1) {
// Only send embeds, files, etc. with the last message
msg = await dmChannel.createMessage(chunk, file);
} else {
msg = await dmChannel.createMessage(chunk);
}
firstMessage = firstMessage || msg;
}
} else {
// Content is a full message content object, send it as-is with the files (if any)
firstMessage = await dmChannel.createMessage(content, file);
}
return firstMessage;
return dmChannel.createMessage(content, file);
}
/**