Skip to content

Commit

Permalink
fix: handle parallel airdrops (#1612)
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnh12 authored Feb 7, 2024
1 parent 193c35e commit 9670eda
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/commands/airdrop/index/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ async function checkExpiredAirdrop(
const usdAmount = amount * token_price

airdropCache.on("expired", (key, participants: string[]) => {
airdropCache.emit(`${cacheKey}-expired`, cacheKey, participants)
})

airdropCache.once(`${cacheKey}-expired`, (key, participants: string[]) => {
wrapError(i.message as Message, async () => {
if (key !== cacheKey) {
return
Expand Down Expand Up @@ -427,8 +431,8 @@ async function enterAirdrop(
embeds: [replyEmbed],
}),
])
if (opts.entries && participants.length === opts.entries) {
airdropCache.emit("expired", cacheKey, participants)
if (opts.entries && participants.length >= opts.entries) {
airdropCache.emit(`${cacheKey}-expired`, cacheKey, participants)
}
}

Expand Down

0 comments on commit 9670eda

Please sign in to comment.