fix(Util): splitMessage throws an error if a chunk is too large (#3060)

This commit is contained in:
SpaceEEC
2019-02-12 10:14:49 +01:00
committed by GitHub
parent a0ff72b556
commit 1618829cc6

View File

@@ -19,7 +19,9 @@ class Util {
static splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) {
if (text.length <= maxLength) return text;
const splitText = text.split(char);
if (splitText.length === 1) throw new Error('Message exceeds the max length and contains no split characters.');
if (splitText.some(chunk => chunk.length > maxLength)) {
throw new Error('Message exceeds the max length and contains no split characters.');
}
const messages = [''];
let msg = 0;
for (let i = 0; i < splitText.length; i++) {