Skip to content

Commit ec3c0ab

Browse files
committed
Add time to breath in CheckExpiredBansTask.kt
1 parent a1ea313 commit ec3c0ab

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

foxy/src/main/kotlin/net/cakeyfox/foxy/interactions/MessageCommandContext.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ class MessageCommandContext(
5454
}
5555

5656
if (hasTextContent && canSendMessage) {
57+
val original = channel.retrieveMessageById(event.messageId).await()
58+
if (original.isWebhookMessage) return
59+
5760
channel.sendTyping().queue()
5861

59-
val original = channel.retrieveMessageById(event.messageId).await()
6062
val shouldDelete = getGuildData()?.guildSettings?.deleteMessageIfCommandIsExecuted
6163

6264
if (shouldDelete == true) {

foxy/src/main/kotlin/net/cakeyfox/foxy/tasks/CakeInactivityTaxTask.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class CakeInactivityTaxTask(
5757
users.chunked(10).forEach { chunk ->
5858
chunk.map { user ->
5959
semaphore.withPermit {
60+
if (canBypassInactivityTax(user)) {
61+
logger.info { "Skipping inactive user ${user._id}" }
62+
return@withPermit
63+
}
64+
6065
try {
6166
val lastDaily = user.userCakes.lastDaily?.takeUnless {
6267
it == Instant.fromEpochMilliseconds(0)
@@ -76,16 +81,16 @@ class CakeInactivityTaxTask(
7681
if (user.userCakes.balance <= MINIMUM_AMOUNT) return@withPermit
7782

7883
if (daysSinceLastDaily in WARNING_DAYS until TAX_START_DAYS) {
79-
if (canBypassInactivityTax(user)) {
80-
logger.info { "Skipping inactive user ${user._id}" }
81-
return@withPermit
82-
}
83-
8484
if (user.userCakes.warnedAboutInactivityTax != true) {
8585
val userFromDiscord = foxy.shardManager.retrieveUserById(user._id).await()
8686
foxy.utils.sendDirectMessage(userFromDiscord) {
8787
embed {
88-
title = pretty(FoxyEmotes.FoxyCry, locale["tax.cakes.warning.title"])
88+
title = pretty(
89+
FoxyEmotes.FoxyCry,
90+
locale[
91+
"tax.cakes.warning.title"
92+
]
93+
)
8994
description = locale[
9095
"tax.cakes.warning.description",
9196
user._id,

foxy/src/main/kotlin/net/cakeyfox/foxy/tasks/CheckExpiredBansTask.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.cakeyfox.foxy.tasks
22

3+
import kotlinx.coroutines.delay
34
import net.cakeyfox.foxy.FoxyInstance
45
import net.cakeyfox.foxy.utils.AdminUtils
56
import net.cakeyfox.foxy.utils.ClusterUtils.getClusterByShardId
@@ -19,6 +20,7 @@ class CheckExpiredBansTask(
1920
val guildShardId = getShardIdFromGuildId(guildId.toLong(), foxy.config.discord.totalShards)
2021
val guildCluster = getClusterByShardId(foxy, guildShardId)
2122

23+
delay(500) // Time to breath
2224
if (guildCluster.id == foxy.currentCluster.id) {
2325
AdminUtils.removeExpiredBans(foxy, guildId, expiredBans)
2426
} else {

0 commit comments

Comments
 (0)