Skip to content

Commit

Permalink
Remove unnecessary null operators
Browse files Browse the repository at this point in the history
  • Loading branch information
bombies committed Aug 14, 2023
1 parent f764921 commit c2c03f3
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/main/kotlin/main/utils/json/guildconfig/GuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ class GuildConfig(private val guild: Guild) : AbstractGuildConfig(guild) {

suspend fun getTwentyFourSevenMode(): Boolean {
val guildModel = getGuildModel()
val value = guildModel.twenty_four_seven_mode
return if (value == null) {
cache.updateGuild(guild.id) {
twenty_four_seven_mode = false
}
false
} else value
return guildModel.twenty_four_seven_mode
}

suspend fun setTwentyFourSevenMode(value: Boolean) {
Expand Down Expand Up @@ -55,14 +49,14 @@ class GuildConfig(private val guild: Guild) : AbstractGuildConfig(guild) {

private suspend fun getBannedUsers(): List<BannedUser> {
return getGuildModel().banned_users
?.map { user ->
.map { user ->
BannedUser(
user.banned_id,
user.banned_by,
user.banned_at,
user.banned_until
)
} ?: emptyList()
}
}

suspend fun getBannedUsersWithUnbanTimes(): HashMap<Long, Long> {
Expand All @@ -76,7 +70,7 @@ class GuildConfig(private val guild: Guild) : AbstractGuildConfig(guild) {
require(!isBannedUser(uid)) { "This user is already banned!" }

setFields {
banned_users?.add(
banned_users.add(
BannedUserModel(
uid,
modId,
Expand All @@ -91,7 +85,7 @@ class GuildConfig(private val guild: Guild) : AbstractGuildConfig(guild) {
require(isBannedUser(uid)) { "This user isn't banned!" }

setFields {
banned_users?.removeIf { user -> user.banned_id == uid }
banned_users.removeIf { user -> user.banned_id == uid }
}
}

Expand Down

0 comments on commit c2c03f3

Please sign in to comment.