Skip to content

Commit

Permalink
Added more methods to add fields to LazyEmbeds
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed May 24, 2023
1 parent a850d62 commit 1360fbe
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions library/src/main/java/xyz/srnyx/lazylibrary/LazyEmbed.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,20 @@ public LazyEmbed setImage(@Nullable String url) {
return this;
}

/**
* Adds a field to the embed
*
* @param field the field to add
*
* @return this
*/
@NotNull
public LazyEmbed addField(@NotNull MessageEmbed.Field field) {
builder.addField(field);
fields.add(field);
return this;
}

/**
* Adds a field to the embed
*
Expand All @@ -457,9 +471,20 @@ public LazyEmbed setImage(@Nullable String url) {
*/
@NotNull
public LazyEmbed addField(@NotNull String name, @NotNull String value, boolean inline) {
final MessageEmbed.Field field = new MessageEmbed.Field(name, value, inline);
builder.addField(field);
fields.add(field);
return addField(new MessageEmbed.Field(name, value, inline));
}

/**
* Adds multiple fields to the embed
*
* @param fields the fields to add
*
* @return this
*/
@NotNull
public LazyEmbed addFields(@NotNull Collection<MessageEmbed.Field> newFields) {
newFields.forEach(builder::addField);
fields.addAll(newFields);
return this;
}

Expand Down

0 comments on commit 1360fbe

Please sign in to comment.