mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
Add RichEmbed fields error handling (#1243)
* RichEmbed fields error handling * Fix consistency * Update RichEmbed.js
This commit is contained in:
committed by
Schuyler Cebulskie
parent
14ae7cdf17
commit
bbd89585c6
@@ -150,9 +150,11 @@ class RichEmbed {
|
|||||||
if (this.fields.length >= 25) throw new RangeError('RichEmbeds may not exceed 25 fields.');
|
if (this.fields.length >= 25) throw new RangeError('RichEmbeds may not exceed 25 fields.');
|
||||||
name = resolveString(name);
|
name = resolveString(name);
|
||||||
if (name.length > 256) throw new RangeError('RichEmbed field names may not exceed 256 characters.');
|
if (name.length > 256) throw new RangeError('RichEmbed field names may not exceed 256 characters.');
|
||||||
|
if (!/\S/.test(name)) throw new RangeError('RichEmbed field names may not be empty.');
|
||||||
value = resolveString(value);
|
value = resolveString(value);
|
||||||
if (value.length > 1024) throw new RangeError('RichEmbed field values may not exceed 1024 characters.');
|
if (value.length > 1024) throw new RangeError('RichEmbed field values may not exceed 1024 characters.');
|
||||||
this.fields.push({ name: String(name), value: value, inline });
|
if (!/\S/.test(value)) throw new RangeError('RichEmbed field values may not be empty.');
|
||||||
|
this.fields.push({ name, value, inline });
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user