Skip to content

refactor(kommand)!: halve the command executor API with context parameters - #20

Merged
oglassdev merged 1 commit into
mainfrom
refactor/kommand-context-parameters
Oct 14, 2026
Merged

oglassdev merged 1 commit into
mainfrom
refactor/kommand-context-parameters

Conversation

@oglassdev

Copy link
Copy Markdown
Owner

Every command executor builder came in two overloads, (sender) and (sender, ctx), and argument access required wrapping the CommandContext in a KommandExecutorContext value class just to put Argument<T>.invoke() in scope. Kotlin 2.4 stabilized context parameters, which are built for exactly this.

Now CommandContext is passed as a context parameter, and arg() is a top-level context(CommandContext) function. Executor DSL usage looks the same:

syntax(value) { sender -> sender.sendMessage(value()) }

Twelve executor functions are now six, and the wrapper class is gone.

Breaking changes

  • KommandExecutorContext is removed. To call arguments, import net.bladehunt.kotstom.command.invoke.
  • The (sender, ctx) executor overloads are removed.
  • Kommand.defaultExecutorAsync loses its scope: CoroutineScope parameter. It was ignored before, and context: CoroutineContext = MinestomDispatcher is what actually applied.

Testing

  • compileTestKotlin and :example:compileKotlin pass.
  • KommandTest passes (3/3).

…ameter

Replace the KommandExecutorContext wrapper with a top-level
context(CommandContext) Argument.invoke(), and collapse the paired
(sender) / (sender, ctx) executor overloads into one.

BREAKING CHANGE: KommandExecutorContext is removed. Import
net.bladehunt.kotstom.command.invoke to call arguments, and use the
(sender) executor lambdas. Kommand.defaultExecutorAsync no longer takes
an (unused) scope parameter.
@oglassdev
oglassdev merged commit 1790d7f into main Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant