mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
feat(Util): resolve text parameter of splitMessage to a string (#3212)
This commit is contained in:
parent
52b4f09e58
commit
abd9d36816
1 changed files with 2 additions and 1 deletions
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue