feat(*): enforce strings (#4880)

BREAKING CHANGE: Removes all Resolvables for only string inputs

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
Souji
2021-06-01 17:31:49 +02:00
committed by GitHub
parent 66a6a1fced
commit 7b85a7259f
14 changed files with 97 additions and 153 deletions

View File

@@ -265,8 +265,8 @@ class MessageEmbed {
/**
* Adds a field to the embed (max 25).
* @param {StringResolvable} name The name of this field
* @param {StringResolvable} value The value of this field
* @param {string} name The name of this field
* @param {string} value The value of this field
* @param {boolean} [inline=false] If this field will be displayed inline
* @returns {MessageEmbed}
*/
@@ -309,13 +309,13 @@ class MessageEmbed {
/**
* Sets the author of this embed.
* @param {StringResolvable} name The name of the author
* @param {string} name The name of the author
* @param {string} [iconURL] The icon URL of the author
* @param {string} [url] The URL of the author
* @returns {MessageEmbed}
*/
setAuthor(name, iconURL, url) {
this.author = { name: Util.resolveString(name), iconURL, url };
this.author = { name: Util.verifyString(name, RangeError, 'EMBED_AUTHOR_NAME'), iconURL, url };
return this;
}
@@ -331,24 +331,22 @@ class MessageEmbed {
/**
* Sets the description of this embed.
* @param {StringResolvable} description The description
* @param {string} description The description
* @returns {MessageEmbed}
*/
setDescription(description) {
description = Util.resolveString(description);
this.description = description;
this.description = Util.verifyString(description, RangeError, 'EMBED_DESCRIPTION');
return this;
}
/**
* Sets the footer of this embed.
* @param {StringResolvable} text The text of the footer
* @param {string} text The text of the footer
* @param {string} [iconURL] The icon URL of the footer
* @returns {MessageEmbed}
*/
setFooter(text, iconURL) {
text = Util.resolveString(text);
this.footer = { text, iconURL };
this.footer = { text: Util.verifyString(text, RangeError, 'EMBED_FOOTER_TEXT'), iconURL };
return this;
}
@@ -385,12 +383,11 @@ class MessageEmbed {
/**
* Sets the title of this embed.
* @param {StringResolvable} title The title
* @param {string} title The title
* @returns {MessageEmbed}
*/
setTitle(title) {
title = Util.resolveString(title);
this.title = title;
this.title = Util.verifyString(title, RangeError, 'EMBED_TITLE');
return this;
}
@@ -437,21 +434,23 @@ class MessageEmbed {
/**
* Normalizes field input and resolves strings.
* @param {StringResolvable} name The name of the field
* @param {StringResolvable} value The value of the field
* @param {string} name The name of the field
* @param {string} value The value of the field
* @param {boolean} [inline=false] Set the field to display inline
* @returns {EmbedField}
*/
static normalizeField(name, value, inline = false) {
name = Util.resolveString(name);
value = Util.resolveString(value);
return { name, value, inline };
return {
name: Util.verifyString(name, RangeError, 'EMBED_FIELD_NAME', false),
value: Util.verifyString(value, RangeError, 'EMBED_FIELD_VALUE', false),
inline,
};
}
/**
* @typedef {Object} EmbedFieldData
* @property {StringResolvable} name The name of this field
* @property {StringResolvable} value The value of this field
* @property {string} name The name of this field
* @property {string} value The value of this field
* @property {boolean} [inline] If this field will be displayed inline
*/