From 41da1617d725f780d7ef45358ce5dbddc563978c Mon Sep 17 00:00:00 2001 From: Speediestsaf Date: Thu, 24 Jul 2025 16:33:46 +0000 Subject: [PATCH] Added the cmd_rotation command for Speed's work rotation. --- commands.json | 3 ++- methods.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/commands.json b/commands.json index 530848d..feb63e9 100644 --- a/commands.json +++ b/commands.json @@ -6,5 +6,6 @@ "cmd_checkpoints": ["checkpoints", "check"], "cmd_addcommand": ["addcommand"], "cmd_listcommands": ["listcommands", "list"], - "cmd_roll": ["roll", "r"] + "cmd_roll": ["roll", "r"], + "cmd_rotation": ["rotation"] } diff --git a/methods.py b/methods.py index 00f84c7..834cc31 100644 --- a/methods.py +++ b/methods.py @@ -155,3 +155,46 @@ def savepoints(points_data): def rolldie(sides): return random.randint(1, sides) +# Define the rotation start date (Week 1) +ROTATION_START_DATE = datetime.date(2025, 7, 14) + +#@bot.command(name='rotation') +async def cmd_rotation(ctx): + # Get today's date + today = datetime.date.today() # For this example, assume July 24, 2025 + + # Calculate days since the start of the rotation + days_since_start = (today - ROTATION_START_DATE).days + + # Calculate current week number (1, 2, or 3) + current_week = (days_since_start // 7 % 3) + 1 + + # Determine the status based on the week number + if current_week == 1 or current_week == 2: + status = "Work from home" + else: # current_week == 3 + status = "Working at the office" + + # Find the Monday of the current week + # weekday() returns 0 for Monday, 1 for Tuesday, etc. + current_monday = today - datetime.timedelta(days=today.weekday()) + + # Calculate weeks to add to reach the next Week 3 + if current_week == 1: + weeks_to_add = 2 + elif current_week == 2: + weeks_to_add = 1 + else: # current_week == 3 + weeks_to_add = 3 + + # Calculate the next Week 3 Monday + next_week3_monday = current_monday + datetime.timedelta(weeks=weeks_to_add) + + # Format the response + response = ( + f"You are currently in **Week {current_week}** ({status}).\n" + f"You will be back to working at the office on **{next_week3_monday.strftime('%B %d, %Y')}**." + ) + + # Send the response + await ctx.send(response)