You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Declarative commands should have a flag/option argument type introduced.
Example implementation
val player by username()
val after by optionArgument<Date>()
val order by optionArgument<OrderByEnum>()
val boolean_option by flag()
("history"/ player) {
+ after // Register the after argument+ order // Alternatively call .withKeyValue(order) for java
runs<CommandSender> {
val records =Database.queryHistory(player)
.recordsAfterDate(after())
.orderBy(order())
.get()
if (records.isEmpty)
return@runs reply(!"&cThat user has no records.")
for (record in records) {
reply(!record)
}
}
} register this
These arguments should have permissions requirements for whomever executes them.
val max_results by optionArgument<Int>()
// `value` is the supplied value as an Int at invocation.
max_results requires { sender.getHighestPermissionLevel("history.max_results") >= value }
max_results permission { sender.reply(!"&cYou can't query that many max results!") }
max_resutls default 10// ...
Matt-MX
changed the title
Key-Value arguments
Option & Flag arguments
Jun 13, 2024
Declarative commands should have a flag/option argument type introduced.
Example implementation
This example command would be invoked like this:
The argument type's format should be relatively customizable.
The text was updated successfully, but these errors were encountered: