Skip to content

[Feature] 关于 command 作用域的 parameter 函数简化 #7

@Aliorpse

Description

@Aliorpse

待 Context Parameters 稳定后,原本

        command("order") {
            val id = parameter<Int>("id")
            val note = greedyStringParameter("note")

            onExecute {
                respond {
                    text("Order #${id.value} created\nnote:${note.value}")
                }
            }
        }

这样的写法可以简化为

        command("order") {
            val id by parameter<Int>("id")
            val note by greedyStringParameter("note")

            onExecute {
                respond {
                    text("Order #$id created\nnote:$note")
                }
            }
        }

这里新增一个 SaltifyCommandExecutionContext 约束的 getValue 就能实现,或者在委托内部持有 SaltifyCommandParamDef

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions