Skip to content

Commit

Permalink
Fix member count milestone triggering with decreasing value
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtsyum authored Aug 8, 2023
1 parent 3b08b36 commit 2c530c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/events/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ const recordMemberCount = async () => {
if(group.memberCount === lastMemberCount) return;

if(config.memberCount.milestone) {
if((group.memberCount % config.memberCount.milestone === 0) || (lastRemainder > (group.memberCount % config.memberCount.milestone))) {
const currentRemainder = group.memberCount % config.memberCount.milestone;
if (lastMemberCount < group.memberCount && (currentRemainder === 0 || lastRemainder > currentRemainder)) {
memberCountChannel.send({ embeds: [ getMemberCountMilestoneEmbed(group.memberCount) ] });
} else {
if(!config.memberCount.onlyMilestones) {
if (!config.memberCount.onlyMilestones) {
memberCountChannel.send({ content: getMemberCountMessage(lastMemberCount, group.memberCount) });
}
}

lastRemainder = currentRemainder;
} else {
memberCountChannel.send({ content: getMemberCountMessage(lastMemberCount, group.memberCount) });
}

lastMemberCount = group.memberCount;
Expand Down

0 comments on commit 2c530c9

Please sign in to comment.