diff --git a/backend/mirai-console/src/test/java/net/mamoe/mirai/console/command/TestCommands.kt b/backend/mirai-console/src/test/java/net/mamoe/mirai/console/command/TestCommands.kt index cb685fab0..717b32979 100644 --- a/backend/mirai-console/src/test/java/net/mamoe/mirai/console/command/TestCommands.kt +++ b/backend/mirai-console/src/test/java/net/mamoe/mirai/console/command/TestCommands.kt @@ -12,6 +12,7 @@ package net.mamoe.mirai.console.command import kotlinx.coroutines.runBlocking +import net.mamoe.mirai.Bot import net.mamoe.mirai.console.plugins.PluginBase import net.mamoe.mirai.message.data.* import org.junit.jupiter.api.Test @@ -30,9 +31,9 @@ internal object TestCommand : PluginCommand( param() } ) { - override suspend fun onCommand(sender: CommandSender, args: CommandArgs): Boolean { + override suspend fun CommandSender.onCommand(args: CommandArgs): Boolean { val s = args.getReified() - sender.sendMessage(s) + sendMessage(s) return true } } @@ -62,9 +63,9 @@ internal class TestCommands { param() } ) { - override suspend fun onCommand(sender: CommandSender, args: CommandArgs): Boolean { + override suspend fun CommandSender.onCommand(args: CommandArgs): Boolean { val s = args.getReified() - sender.sendMessage(s) + sendMessage(s) return true } }.register() @@ -87,11 +88,10 @@ internal class TestCommands { internal inline fun withSender(block: CommandSender.() -> Unit): MessageChain { val result = MessageChainBuilder() val sender: CommandSender = object : CommandSender { - override suspend fun sendMessage(message: Message) { - result.add(message) - } + override val bot: Bot? + get() = null - override suspend fun sendMessage(message: String) { + override suspend fun sendMessage(message: Message) { result.add(message) }