mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user