Skip to content

Commit

Permalink
DiscordEmbedTag.output_length
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 14, 2021
1 parent b3a7f36 commit ef6e61b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,20 @@ else if (key.equals("color")) {
fieldList.addObject(fieldMap);
return embed;
});

// <--[tag]
// @attribute <DiscordEmbedTag.output_length>
// @returns ElementTag(Number)
// @plugin dDiscordBot
// @description
// Returns the total number of displayed characters this embed contains.
// Discord rejects embeds with a total character count above 6000.
// There are other limits for embed objects, refer to <@link url https://discordjs.guide/popular-topics/embeds.html#embed-limits>
//
// -->
tagProcessor.registerTag(ElementTag.class, "output_length", (attribute, object) -> {
return new ElementTag(object.duplicate().build(attribute.context).length());
});
}

public static ObjectTagProcessor<DiscordEmbedTag> tagProcessor = new ObjectTagProcessor<>();
Expand Down

0 comments on commit ef6e61b

Please sign in to comment.