@@ -611,15 +611,29 @@ async def backpay_cmd(self, ctx: commands.Context, duration: commands.TimedeltaC
611611 if uid not in accounts or uid not in ecousers :
612612 continue
613613
614- # Get their last payday time
615- last_payday = ecousers [uid ].get ("next_payday" , 0 )
614+ # Calculate how many paydays they could have claimed
615+ next_payday_timestamp = ecousers [uid ].get ("next_payday" , 0 )
616616
617- # If their last payday is after our lookback time, skip
618- if last_payday > lookback_time :
619- continue
617+ # Calculate how many full payday periods have passed since lookback_time
618+ # Handle case where user has never claimed a payday
619+ if next_payday_timestamp == 0 :
620+ # User has never claimed payday, assume they could claim from the lookback time
621+ potential_paydays = (current_time - lookback_time ) // payday_time
622+ else :
623+ # Check if user's next payday is after our lookback time
624+ if next_payday_timestamp > lookback_time :
625+ # Calculate how many complete payday periods have passed
626+ # between their next available payday and now
627+ time_since_next_available = max (0 , current_time - next_payday_timestamp )
628+ potential_paydays = time_since_next_available // payday_time
629+ else :
630+ # They could have claimed from the lookback time to now,
631+ # plus one more if their next payday was before lookback
632+ potential_paydays = (current_time - lookback_time ) // payday_time
633+ # Add 1 if they could have claimed right at lookback time
634+ if next_payday_timestamp <= lookback_time :
635+ potential_paydays += 1
620636
621- # Calculate how many paydays they could have claimed
622- potential_paydays = (current_time - last_payday ) // payday_time
623637 if potential_paydays <= 0 :
624638 continue
625639
@@ -676,15 +690,29 @@ async def backpay_cmd(self, ctx: commands.Context, duration: commands.TimedeltaC
676690 if uid not in accounts or uid not in ecousers :
677691 continue
678692
679- # Get their last payday time
680- last_payday = ecousers [uid ].get ("next_payday" , 0 )
693+ # Calculate how many paydays they could have claimed
694+ next_payday_timestamp = ecousers [uid ].get ("next_payday" , 0 )
681695
682- # If their last payday is after our lookback time, skip
683- if last_payday > lookback_time :
684- continue
696+ # Calculate how many full payday periods have passed since lookback_time
697+ # Handle case where user has never claimed a payday
698+ if next_payday_timestamp == 0 :
699+ # User has never claimed payday, assume they could claim from the lookback time
700+ potential_paydays = (current_time - lookback_time ) // payday_time
701+ else :
702+ # Check if user's next payday is after our lookback time
703+ if next_payday_timestamp > lookback_time :
704+ # Calculate how many complete payday periods have passed
705+ # between their next available payday and now
706+ time_since_next_available = max (0 , current_time - next_payday_timestamp )
707+ potential_paydays = time_since_next_available // payday_time
708+ else :
709+ # They could have claimed from the lookback time to now,
710+ # plus one more if their next payday was before lookback
711+ potential_paydays = (current_time - lookback_time ) // payday_time
712+ # Add 1 if they could have claimed right at lookback time
713+ if next_payday_timestamp <= lookback_time :
714+ potential_paydays += 1
685715
686- # Calculate how many paydays they could have claimed
687- potential_paydays = (current_time - last_payday ) // payday_time
688716 if potential_paydays <= 0 :
689717 continue
690718
0 commit comments