Skip to content

Commit d8bb76f

Browse files
committed
Added actual length to error messages.
1 parent a64e71a commit d8bb76f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/BetterEmbed.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ class BetterEmbed extends MessageEmbed {
8080
}
8181

8282
public checkSize() {
83-
if (this.title && this.title.length > limits.title) throw new RangeError(`'embed.title' is too long (${limits.title}).`);
84-
if (this.author?.name && this.author.name.length > limits.author.name) throw new RangeError(`'embed.author.name' is too long (${limits.author.name}).`);
85-
if (this.description && this.description.length > limits.description) throw new RangeError(`'embed.description' is too long (${limits.description}).`);
83+
if (this.title && this.title.length > limits.title) throw new RangeError(`'embed.title' is too long: ${this.title.length} (max: ${limits.title}).`);
84+
if (this.author?.name && this.author.name.length > limits.author.name) throw new RangeError(`'embed.author.name' is too long: ${this.author.name.length} (max: ${limits.author.name}).`);
85+
if (this.description && this.description.length > limits.description) throw new RangeError(`'embed.description' is too long: ${this.description.length} (max: ${limits.description}).`);
8686
if (this.fields?.length > limits.fields.size) throw new RangeError(`Too much fields (${limits.fields.size}).`);
8787
this.fields.forEach(field => {
88-
if (field.name?.length > limits.fields.name) throw new RangeError(`'embed.fields[${this.fields.indexOf(field)}].name' is too long (${limits.fields.name}).`);
89-
if (field.value?.length > limits.fields.value) throw new RangeError(`'embed.fields[${this.fields.indexOf(field)}].value' is too long (${limits.fields.value}).`);
88+
if (field.name?.length > limits.fields.name) throw new RangeError(`'embed.fields[${this.fields.indexOf(field)}].name' is too long: ${field.name.length} (max: ${limits.fields.name}).`);
89+
if (field.value?.length > limits.fields.value) throw new RangeError(`'embed.fields[${this.fields.indexOf(field)}].value' is too long: ${field.value.length} (max: ${limits.fields.value}).`);
9090
});
9191
}
9292

0 commit comments

Comments
 (0)