fix(Util): throw an explicit error if a chunk exceeds the max length (#2936)

* fix(Util): throw an explicit error if a chunk exceeds the max length

* refactor(Util): consolidate both errors in splitMessage into one

* revert(Messages): do not unnecessarily change the error code

* revert(Messages): do not remove the word 'the'
This commit is contained in:
SpaceEEC
2018-11-27 21:42:28 +01:00
committed by GitHub
parent 23a16c3a73
commit ecaec29380
2 changed files with 2 additions and 4 deletions

View File

@@ -56,7 +56,7 @@ class Util {
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
if (text.length <= maxLength) return text;
const splitText = text.split(char);
if (splitText.length === 1) throw new RangeError('SPLIT_MAX_LEN');
if (splitText.some(chunk => chunk.length > maxLength)) throw new RangeError('SPLIT_MAX_LEN');
const messages = [];
let msg = '';
for (const chunk of splitText) {