Skip to content

Commit

Permalink
feat(Util): resolve text parameter of splitMessage to a string (#3212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Purpzie authored and SpaceEEC committed Apr 21, 2019
1 parent 52b4f09 commit abd9d36
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util/Util.js
Expand Up @@ -51,11 +51,12 @@ class Util {

/**
* Splits a string into multiple chunks at a designated character that do not exceed a specific length.
* @param {string} text Content to split
* @param {StringResolvable} text Content to split
* @param {SplitOptions} [options] Options controlling the behavior of the split
* @returns {string|string[]}
*/
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
text = this.resolveString(text);
if (text.length <= maxLength) return text;
const splitText = text.split(char);
if (splitText.some(chunk => chunk.length > maxLength)) throw new RangeError('SPLIT_MAX_LEN');
Expand Down

0 comments on commit abd9d36

Please sign in to comment.