mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
fix(Util): splitMessage throws an error if a chunk is too large (#3060)
This commit is contained in:
@@ -19,7 +19,9 @@ class Util {
|
|||||||
static splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) {
|
static splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) {
|
||||||
if (text.length <= maxLength) return text;
|
if (text.length <= maxLength) return text;
|
||||||
const splitText = text.split(char);
|
const splitText = text.split(char);
|
||||||
if (splitText.length === 1) throw new Error('Message exceeds the max length and contains no split characters.');
|
if (splitText.some(chunk => chunk.length > maxLength)) {
|
||||||
|
throw new Error('Message exceeds the max length and contains no split characters.');
|
||||||
|
}
|
||||||
const messages = [''];
|
const messages = [''];
|
||||||
let msg = 0;
|
let msg = 0;
|
||||||
for (let i = 0; i < splitText.length; i++) {
|
for (let i = 0; i < splitText.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user