如何从哈希映射运行函数。在本例中,我尝试运行 Info.sendInfo 函数。
abstract class Listener: ListenerAdapter() {
fun checkCommand(args: List<String>, event: MessageReceivedEvent) {
val map: Map<String, Unit> = mapOf(
"!info" to Info.sendInfo(event)
)
map[args[0]].runFunction
}
}
Run Code Online (Sandbox Code Playgroud)