// 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()
Is your feature request related to a problem?
To be able to re-use static string templates with dynamic variables.
https://github.com/axieum/minecord/blob/f1a5703910c5c70c5eb0f5d7d656620f791b55d0/minecord-api/src/main/java/me/axieum/mcmod/minecord/api/util/StringTemplate.java#L198
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,
https://github.com/axieum/minecord/blob/c7025e2792c4030500bd7423c7c3e86ca1dddc66/minecord-cmds/src/main/java/me/axieum/mcmod/minecord/impl/cmds/command/discord/UptimeCommand.java#L23
...to something like,
...and then we can reuse that template in the execution to save instantiating a new template every time!
Describe alternatives you've considered.
https://github.com/axieum/minecord/blob/c7025e2792c4030500bd7423c7c3e86ca1dddc66/minecord-cmds/src/main/java/me/axieum/mcmod/minecord/impl/cmds/command/discord/UptimeCommand.java#L49-L51
Agreements
Other
No response