mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
Add more errors for RichEmbed builder char limits (#954)
* Add more errors for RichEmbed builder char limits Might as well if we're erroring on number of fields when that's the one limit that doesn't actually throw a bad request. * Fix name.length check in previous commit * Update RichEmbed.js * Update number of fields error message
This commit is contained in:
committed by
Schuyler Cebulskie
parent
8eff36b744
commit
daa79b7f97
@@ -71,6 +71,7 @@ class RichEmbed {
|
|||||||
* @returns {RichEmbed} This embed
|
* @returns {RichEmbed} This embed
|
||||||
*/
|
*/
|
||||||
setTitle(title) {
|
setTitle(title) {
|
||||||
|
if (title.length > 256) throw new RangeError('RichEmbed titles may not exceed 256 characters.');
|
||||||
this.title = title;
|
this.title = title;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,7 @@ class RichEmbed {
|
|||||||
* @returns {RichEmbed} This embed
|
* @returns {RichEmbed} This embed
|
||||||
*/
|
*/
|
||||||
setDescription(description) {
|
setDescription(description) {
|
||||||
|
if (description.length > 2048) throw new RangeError('RichEmbed descriptions may not exceed 2048 characters.');
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -139,7 +141,9 @@ class RichEmbed {
|
|||||||
* @returns {RichEmbed} This embed
|
* @returns {RichEmbed} This embed
|
||||||
*/
|
*/
|
||||||
addField(name, value, inline = false) {
|
addField(name, value, inline = false) {
|
||||||
if (this.fields.length >= 25) throw new RangeError('A RichEmbed may only have a maximum of 25 fields.');
|
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 (value.length > 1024) throw new RangeError('RichEmbed field values may not exceed 1024 characters.');
|
||||||
this.fields.push({ name, value, inline });
|
this.fields.push({ name, value, inline });
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -171,6 +175,7 @@ class RichEmbed {
|
|||||||
* @returns {RichEmbed} This embed
|
* @returns {RichEmbed} This embed
|
||||||
*/
|
*/
|
||||||
setFooter(text, icon) {
|
setFooter(text, icon) {
|
||||||
|
if (text.length > 2048) throw new RangeError('RichEmbed footer text may not exceed 1024 characters.');
|
||||||
this.footer = { text, icon_url: icon };
|
this.footer = { text, icon_url: icon };
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user