This commit is contained in:
UnrealValentin
2021-06-02 22:58:54 +02:00
parent 5511d1c5ac
commit 1f3ebc42e6
3 changed files with 5 additions and 9 deletions

View File

@@ -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")}

View File

@@ -123,13 +123,9 @@ object Channels {
fun refreshServiceChannelsFromDisk() =
Json.decodeFromString<List<ServiceChannel>>(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<String>? = 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 -> ""

View File

@@ -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")}