Skip to content

Commit

Permalink
fixed cached last active members value
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Oct 27, 2024
1 parent 9785f12 commit 33d7a15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/listeners/activity.ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as app from "#app"

const intervals: Record<string, NodeJS.Timeout> = {}

let lastActiveCount = 0

const listener: app.Listener<"ready"> = {
event: "ready",
description: "Start an interval to update the active list",
Expand Down Expand Up @@ -48,6 +46,10 @@ const listener: app.Listener<"ready"> = {
return
}

const cacheId = `lastActiveCount.${guild.id}`

const lastActiveCount = app.cache.ensure(cacheId, 0)

if (found > lastActiveCount) {
await app.sendLog(
realGuild,
Expand All @@ -64,7 +66,7 @@ const listener: app.Listener<"ready"> = {
)
}

lastActiveCount = found
app.cache.set(cacheId, found)
},
interval * 1000 * 60 * 60,
)
Expand Down
5 changes: 4 additions & 1 deletion src/namespaces/automod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export async function detectAndBanSpammer(message: app.Message) {
await general.send(
`${app.emote(message, "CheckMark")} **${
message.author.tag
}** detected as a spammer and banned from **${success}** labs.\n> **${errored}** labs failed to ban the user.`,
}** detected as a spammer and banned from **${success}** labs.\n**${errored}** labs failed to ban the user Reasons:\n${result
.filter((result) => result.status === "rejected")
.map((result) => `- ${result.reason}`)
.join("\n")}`,
)
} else {
await general.send(
Expand Down

0 comments on commit 33d7a15

Please sign in to comment.