Skip to content

Commit

Permalink
Fix bug with adding restricted channels
Browse files Browse the repository at this point in the history
  • Loading branch information
bombies committed Sep 16, 2023
1 parent 37d42c9 commit dab4b7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class GuildRedisCache private constructor() : DatabaseRedisCache("ROBERTIFY_GUIL
val handleRestrictedChannels: (arr: JSONArray) -> JSONArray = { arr ->
val newArr = JSONArray()
if (!arr.isEmpty && arr[0] is Long) {
rtc.toList().forEach { item: Any ->
arr.toList().forEach { item: Any ->
if (item.toString().isDiscordId())
newArr.put(item.toString())
}
Expand Down Expand Up @@ -138,11 +138,10 @@ class GuildRedisCache private constructor() : DatabaseRedisCache("ROBERTIFY_GUIL
)
}
}

return obj
}

fun correctGuildObj(obj: JSONObject?): JSONObject {
private fun correctGuildObj(obj: JSONObject?): JSONObject {
if (!obj!!.has(GuildDB.Field.GUILD_ID.toString())) return obj
if (obj.has("_id")) obj.remove("_id")
if (obj.has("__v")) obj.remove("__v")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package main.utils.json.restrictedchannels

import dev.minn.jda.ktx.util.SLF4J
import main.utils.database.mongodb.databases.GuildDB
import main.utils.json.AbstractGuildConfig
import main.utils.json.getIndexOfObjectInArray
import net.dv8tion.jda.api.entities.Guild

class RestrictedChannelsConfig(private val guild: Guild) : AbstractGuildConfig(guild) {
companion object {
private val logger by SLF4J
}

suspend fun addChannel(channelID: Long, type: ChannelType?) {
val configField: GuildDB.Field = when (type) {
Expand Down

0 comments on commit dab4b7c

Please sign in to comment.