diff --git a/src/main/kotlin/moe/kageru/kagebot/features/SetConfigFeature.kt b/src/main/kotlin/moe/kageru/kagebot/features/SetConfigFeature.kt index 8716e51..a3bdf81 100644 --- a/src/main/kotlin/moe/kageru/kagebot/features/SetConfigFeature.kt +++ b/src/main/kotlin/moe/kageru/kagebot/features/SetConfigFeature.kt @@ -4,6 +4,7 @@ import moe.kageru.kagebot.Log import moe.kageru.kagebot.MessageUtil.sendEmbed import moe.kageru.kagebot.config.ConfigParser import moe.kageru.kagebot.config.RawConfig +import org.javacord.api.entity.channel.TextChannel import org.javacord.api.event.message.MessageCreateEvent class SetConfigFeature : MessageFeature() { @@ -17,13 +18,7 @@ class SetConfigFeature : MessageFeature() { val rawConfig = try { RawConfig.readFromString(newConfig) } catch (e: IllegalStateException) { - message.channel.sendEmbed { - addField( - "An unexpected error occured. This is probably caused by a malformed config file. Perhaps this can help:", - "```$e: ${e.message}" - ) - } - Log.info("Could not parse new config: $e: ${e.message}") + reportError(message.channel, e) return } try { @@ -38,4 +33,15 @@ class SetConfigFeature : MessageFeature() { } } } + + private fun reportError(message: TextChannel, e: IllegalStateException) { + message.sendEmbed { + addField( + "An unexpected error occured. This is probably caused by a malformed config file. Perhaps this can help:", + "```$e: ${e.message}" + ) + } + Log.info("Could not parse new config: $e: ${e.message}") + return + } }