Add RichEmbed fields error handling (#1243)

* RichEmbed fields error handling

* Fix consistency

* Update RichEmbed.js
This commit is contained in:
1Computer1
2017-03-09 20:58:46 -05:00
committed by Schuyler Cebulskie
parent 14ae7cdf17
commit bbd89585c6

View File

@@ -150,9 +150,11 @@ class RichEmbed {
if (this.fields.length >= 25) throw new RangeError('RichEmbeds may not exceed 25 fields.');
name = resolveString(name);
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);
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;
}