Skip to content

Commit

Permalink
feat: Clean cooldown info
Browse files Browse the repository at this point in the history
  • Loading branch information
SantioMC committed Apr 25, 2024
1 parent 87de336 commit 758c638
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ class CooldownCommand {
}

val cooldowns = CooldownRegistry.cooldowns[e.user.id] ?: emptySet()
val defaultCooldowns = Cooldown.Kind.entries.distinctBy { it.channel }

var body = """
| :clipboard: Channel Cooldowns
|
| **Server Cooldowns**
${Cooldown.Kind.entries.joinToString("\n") {
val name = it.display
${defaultCooldowns.joinToString("\n") {
val name = it.channel.display
val duration = DurationResolver.pretty(it.getDuration())
"| $name: $duration"
Expand Down
11 changes: 6 additions & 5 deletions src/main/kotlin/me/santio/minehututils/cooldown/Cooldown.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.santio.minehututils.cooldown

import me.santio.minehututils.data.Channel
import me.santio.minehututils.resolvers.DurationResolver
import me.santio.minehututils.resolvers.DurationResolver.pretty
import me.santio.minehututils.utils.EnvUtils.env
Expand Down Expand Up @@ -41,11 +42,11 @@ data class Cooldown(
return pretty(Duration.ofSeconds(remaining))
}

enum class Kind(val display: String, private val envVariable: String) {
ADVERTISEMENT_SERVER("Advertisement (Server)", "ADVERT_COOLDOWN"),
ADVERTISEMENT_USER("Advertisement (User)", "ADVERT_COOLDOWN"),
MARKET_OFFER("Marketplace (Offer)", "MARKET_COOLDOWN"),
MARKET_REQUEST("Marketplace (Request)", "MARKET_COOLDOWN"),
enum class Kind(val display: String, val channel: Channel, private val envVariable: String) {
ADVERTISEMENT_SERVER("Advertisement (Server)", Channel.ADVERTISEMENTS, "ADVERT_COOLDOWN"),
ADVERTISEMENT_USER("Advertisement (User)", Channel.ADVERTISEMENTS, "ADVERT_COOLDOWN"),
MARKET_OFFER("Marketplace (Offer)", Channel.MARKETPLACE, "MARKET_COOLDOWN"),
MARKET_REQUEST("Marketplace (Request)", Channel.MARKETPLACE, "MARKET_COOLDOWN"),
;

fun getDuration(): Duration {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/me/santio/minehututils/data/Channel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package me.santio.minehututils.data

import me.santio.minehututils.utils.EnvUtils.env

enum class Channel(private val envVariable: String) {
enum class Channel(val display: String, private val envVariable: String) {

ADVERTISEMENTS("ADVERT_CHANNEL"),
MARKETPLACE("MARKET_CHANNEL"),
ADVERTISEMENTS("Advertisements", "ADVERT_CHANNEL"),
MARKETPLACE("Marketplace", "MARKET_CHANNEL"),
;

fun get(): String? {
Expand Down

0 comments on commit 758c638

Please sign in to comment.