mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00: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:
parent
8eff36b744
commit
daa79b7f97
1 changed files with 6 additions and 1 deletions
|
|
@ -71,6 +71,7 @@ class RichEmbed {
|
|||
* @returns {RichEmbed} This embed
|
||||
*/
|
||||
setTitle(title) {
|
||||
if (title.length > 256) throw new RangeError('RichEmbed titles may not exceed 256 characters.');
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
|
@ -81,6 +82,7 @@ class RichEmbed {
|
|||
* @returns {RichEmbed} This embed
|
||||
*/
|
||||
setDescription(description) {
|
||||
if (description.length > 2048) throw new RangeError('RichEmbed descriptions may not exceed 2048 characters.');
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
|
@ -139,7 +141,9 @@ class RichEmbed {
|
|||
* @returns {RichEmbed} This embed
|
||||
*/
|
||||
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 });
|
||||
return this;
|
||||
}
|
||||
|
|
@ -171,6 +175,7 @@ class RichEmbed {
|
|||
* @returns {RichEmbed} This embed
|
||||
*/
|
||||
setFooter(text, icon) {
|
||||
if (text.length > 2048) throw new RangeError('RichEmbed footer text may not exceed 1024 characters.');
|
||||
this.footer = { text, icon_url: icon };
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue