Skip to content

Commit

Permalink
discord progress bar: dont report a stage 2 if it is step 0
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed Jan 27, 2024
1 parent 7e539f2 commit 3b9b590
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions discord_tron_client/classes/discord_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ def __init__(
self.last_update = time.time()

async def update_progress_bar(self, step: int):
if step == 0 and self.current_step == 100:
# We might be onto stage two of a multi-stage operation..
self.current_stage += 1
self.current_stage_msg = ' (Stage ' + str(self.current_stage) + ')'
if step < self.current_step:
logging.warn(
f"Step {step} is less than current step {self.current_step}. This means the progress bar tried updating to the same state more than once."
)
self.current_step = step
if step == 0 and self.current_step == 100:
# We might be onto stage two of a multi-stage operation..
self.current_stage += 1
self.current_stage_msg = ' (Stage ' + str(self.current_stage) + ')'
return
progress = self.current_step / self.total_steps
filled_length = int(progress * self.progress_bar_length)
bar = "█" * filled_length + "-" * (self.progress_bar_length - filled_length)
Expand Down

0 comments on commit 3b9b590

Please sign in to comment.