Refactor redundant nonnull assertion

This commit is contained in:
kageru 2019-06-15 12:48:23 +02:00
parent ab1d4729f4
commit cefadba58f
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -38,12 +38,12 @@ class Command(cmd: RawCommand) {
}
this.actions?.run(message, this)
this.response?.let {
message.channel.sendMessage(respond(message.messageAuthor))
message.channel.sendMessage(respond(message.messageAuthor, it))
}
}
fun matches(msg: String) = this.matchType.matches(msg, this)
private fun respond(author: MessageAuthor) = this.response!!.doIf({ it.contains(AUTHOR_PLACEHOLDER) }) {
private fun respond(author: MessageAuthor, response: String) = response.doIf({ it.contains(AUTHOR_PLACEHOLDER) }) {
it.replace(AUTHOR_PLACEHOLDER, MessageUtil.mention(author))
}
}