mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 14:02:02 +00:00
fix(Util): splitMessage throws an error if a chunk is too large (#3060)
This commit is contained in:
parent
a0ff72b556
commit
1618829cc6
1 changed files with 3 additions and 1 deletions
|
|
@ -19,7 +19,9 @@ class Util {
|
|||
static splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) {
|
||||
if (text.length <= maxLength) return text;
|
||||
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 = [''];
|
||||
let msg = 0;
|
||||
for (let i = 0; i < splitText.length; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue