feat: Improve arguments
* Add UserConverter * Add a way to specify default value
This commit is contained in:
parent
fce8afa2b2
commit
04472f8bfa
13 changed files with 119 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
|||
package io.github.null2264.tsukumogami.bot.core.module
|
||||
|
||||
import io.github.null2264.tsukumogami.bot.core.module.arguments.Test2Arguments
|
||||
import io.github.null2264.tsukumogami.bot.core.module.arguments.TestArguments
|
||||
import io.github.null2264.tsukumogami.core.module.api.botModules
|
||||
import kotlinx.datetime.Clock
|
||||
|
@ -13,7 +14,7 @@ val generalModule = botModules("General") {
|
|||
}
|
||||
|
||||
groups("group") {
|
||||
commands("test", arguments = ::TestArguments) { ctx, args -> ctx.send("Hello world ${args.test}") }
|
||||
commands("test", arguments = ::Test2Arguments) { ctx, args -> ctx.send("Hello world ${args.user}") }
|
||||
}
|
||||
|
||||
commands("test", arguments = ::TestArguments) { ctx, args -> ctx.send("Hello world ${args.test}") }
|
||||
|
|
|
@ -2,7 +2,14 @@ package io.github.null2264.tsukumogami.bot.core.module.arguments
|
|||
|
||||
import io.github.null2264.tsukumogami.core.commands.Arguments
|
||||
import io.github.null2264.tsukumogami.core.commands.ext.string
|
||||
import io.github.null2264.tsukumogami.core.commands.ext.user
|
||||
|
||||
class TestArguments : Arguments() {
|
||||
val test by string("Test")
|
||||
val test by string("Test") {
|
||||
default("Lmao")
|
||||
}
|
||||
}
|
||||
|
||||
class Test2Arguments : Arguments() {
|
||||
val user by user("User")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue