Skip to content

Commit

Permalink
feat: Util.splitMessage always return an array (#3035)
Browse files Browse the repository at this point in the history
* Making Util.splitMessage always return an array

Util.splitMessage sometimes returns an array, but other times it returns a string. This should make it so that it always returns an array.

* jsdoc

Co-Authored-By: TNThacker2015 <[email protected]>

* docs(Util): remove superfluous space in docstring
  • Loading branch information
MelnCat authored and iCrawl committed Jul 29, 2019
1 parent 53722b4 commit e645dd6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class Util {
* Splits a string into multiple chunks at a designated character that do not exceed a specific length.
* @param {StringResolvable} text Content to split
* @param {SplitOptions} [options] Options controlling the behavior of the split
* @returns {string|string[]}
* @returns {string[]}
*/
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
text = this.resolveString(text);
if (text.length <= maxLength) return 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');
const messages = [];
Expand Down

0 comments on commit e645dd6

Please sign in to comment.