Small kotlin improvement
This commit is contained in:
parent
361427488f
commit
6567c5e6c7
@ -44,12 +44,11 @@ object CommandParser {
|
||||
return ParsedCommand.ErrorNotACommand
|
||||
}
|
||||
|
||||
var messageParts: List<String>? = null
|
||||
|
||||
try {
|
||||
messageParts = textMessage.split("\\s+".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
val messageParts = try {
|
||||
textMessage.split("\\s+".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## manageSplashCommand() : split failed")
|
||||
null
|
||||
}
|
||||
|
||||
// test if the string cut fails
|
||||
@ -57,9 +56,7 @@ object CommandParser {
|
||||
return ParsedCommand.ErrorEmptySlashCommand
|
||||
}
|
||||
|
||||
val slashCommand = messageParts[0]
|
||||
|
||||
when (slashCommand) {
|
||||
when (val slashCommand = messageParts.first()) {
|
||||
Command.CHANGE_DISPLAY_NAME.command -> {
|
||||
val newDisplayName = textMessage.substring(Command.CHANGE_DISPLAY_NAME.command.length).trim()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user