From 710d3db94fb38d865b05afe5f203c81fe895b9b8 Mon Sep 17 00:00:00 2001 From: bdistin Date: Fri, 9 Dec 2016 21:10:50 -0600 Subject: [PATCH] RichEmbed Tweaks/Improvements (#964) * RichEmbed Tweaks/Improvements Changed .addTimestamp() to .setTimestamp() to bring it inline with all other single value settings. Changed Field value to StringResolveable from String to bring it inline with typical sendMessage functionality. * Lint Fix * Remove Default, Add check for undefined --- src/structures/RichEmbed.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structures/RichEmbed.js b/src/structures/RichEmbed.js index c135a6219..0f1dc915b 100644 --- a/src/structures/RichEmbed.js +++ b/src/structures/RichEmbed.js @@ -133,7 +133,7 @@ class RichEmbed { * @param {Date} [timestamp=current date] The timestamp * @returns {RichEmbed} This embed */ - addTimestamp(timestamp = new Date()) { + setTimestamp(timestamp = new Date()) { this.timestamp = timestamp; return this; } @@ -141,13 +141,17 @@ class RichEmbed { /** * Adds a field to the embed (max 25) * @param {string} name The name of the field - * @param {string} value The value of the field + * @param {StringResolvable} value The value of the field * @param {boolean} [inline=false] Set the field to display inline * @returns {RichEmbed} This embed */ addField(name, value, inline = false) { if (this.fields.length >= 25) throw new RangeError('RichEmbeds may not exceed 25 fields.'); if (name.length > 256) throw new RangeError('RichEmbed field names may not exceed 256 characters.'); + if (typeof value !== 'undefined') { + if (value instanceof Array) value = value.join('\n'); + else if (typeof value !== 'string') value = String(value); + } if (value.length > 1024) throw new RangeError('RichEmbed field values may not exceed 1024 characters.'); this.fields.push({ name, value, inline }); return this;