diff --git a/src/main/kotlin/org/hmcore/Admin.kt b/src/main/kotlin/org/hmcore/Admin.kt index e4c8a30..8d717f9 100644 --- a/src/main/kotlin/org/hmcore/Admin.kt +++ b/src/main/kotlin/org/hmcore/Admin.kt @@ -76,7 +76,7 @@ object Admin { embed { title = "Now watching for new Hytale Blogposts every ${updateMs / 1000}s" description = """ - ${Channels.getServerNames().joinToString("\n")} + ${Channels.getServerNames()?.joinToString("\n")} **_Service Channels_** ${Channels.getServiceChannelServers().joinToString("\n")} diff --git a/src/main/kotlin/org/hmcore/Channels.kt b/src/main/kotlin/org/hmcore/Channels.kt index 3b3b617..dd9a33f 100644 --- a/src/main/kotlin/org/hmcore/Channels.kt +++ b/src/main/kotlin/org/hmcore/Channels.kt @@ -123,13 +123,9 @@ object Channels { fun refreshServiceChannelsFromDisk() = Json.decodeFromString>(SERVICE_CHANNELS_FILE.readText()).toMutableList() - 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)*" - } + 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 val role = when (it.mentionedRole) { null -> "" diff --git a/src/main/kotlin/org/hmcore/OwnerCli.kt b/src/main/kotlin/org/hmcore/OwnerCli.kt index b45b1a1..0c474a8 100644 --- a/src/main/kotlin/org/hmcore/OwnerCli.kt +++ b/src/main/kotlin/org/hmcore/OwnerCli.kt @@ -202,7 +202,7 @@ class OwnerCli : ListenerAdapter() { .setTitle("Server overview") .setColor(Color.GREEN) .setDescription(""" - ${Channels.getServerNames(event.message.guild.idLong).joinToString("\n")} + ${Channels.getServerNames(event.message.guild.idLong)?.joinToString("\n")} **_Service Channels_** ${Channels.getServiceChannelServers(event.message.guild.idLong).joinToString("\n")}