From bbd89585c6a1a57ebc20a274f2f98106e02488f1 Mon Sep 17 00:00:00 2001 From: 1Computer1 <1Computer1@users.noreply.github.com> Date: Thu, 9 Mar 2017 20:58:46 -0500 Subject: [PATCH] Add RichEmbed fields error handling (#1243) * RichEmbed fields error handling * Fix consistency * Update RichEmbed.js --- src/structures/RichEmbed.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/structures/RichEmbed.js b/src/structures/RichEmbed.js index fe787bfaa..302734e66 100644 --- a/src/structures/RichEmbed.js +++ b/src/structures/RichEmbed.js @@ -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; }