Support lazy values in string templates
axieum opened this issue ยท 0 comments
Is your feature request related to a problem?
To be able to re-use static string templates with dynamic variables.
We should be able to quickly check whether the variable is an instance of Supplier<T>
and invoke the supplier for its value instead.
Describe the solution you'd like.
Adjust,
...to something like,
// Prepare a reusable string template for all uptime commands
private static final StringTemplate TEMPLATE = new StringTemplate()
.add("uptime", () -> Duration.ofMillis(ManagementFactory.getRuntimeMXBean().getUptime()));
...and then we can reuse that template in the execution to save instantiating a new template every time!
new EmbedBuilder().setDescription(TEMPLATE.format(getConfig().builtin.uptime.message)).build()
Describe alternatives you've considered.
Agreements
- I have searched for and ensured there isn't already an open issue regarding this.
- I have ensured the feature I'm requesting isn't already in the latest supported mod version.
Other
No response