From 4e2186026c4aa05bfc645ac756e3848c753a1e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wieland=20Sch=C3=B6bl?= Date: Wed, 2 Jun 2021 23:21:50 +0200 Subject: [PATCH] Revert "hotfix 1" This reverts commit 1f3ebc42 --- src/main/kotlin/org/hmcore/Channels.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/hmcore/Channels.kt b/src/main/kotlin/org/hmcore/Channels.kt index dd9a33f..3b3b617 100644 --- a/src/main/kotlin/org/hmcore/Channels.kt +++ b/src/main/kotlin/org/hmcore/Channels.kt @@ -123,9 +123,13 @@ object Channels { fun refreshServiceChannelsFromDisk() = Json.decodeFromString>(SERVICE_CHANNELS_FILE.readText()).toMutableList() - fun getServerNames(server: Long? = null): List? = Main.jdas.flatMap { jda -> - channels.filter { server == null || (jda.getTextChannelById(it.id)?.guild?.idLong == server) }.mapNotNull { - val channel = jda.getTextChannelById(it.id) ?: return@mapNotNull null + fun getServerNames(server: Long? = null) = Main.jdas.flatMap { jda -> + channels.filter { server == null || (jda.getTextChannelById(it.id)?.guild?.idLong == server) }.map { + val channel = jda.getTextChannelById(it.id) + if (channel == null) { + Admin.warning("Channel ${it.id} is no longer active!") + return@map "**${it.id}** *(inactive)*" + } val role = when (it.mentionedRole) { null -> ""