Compare commits
2 commits
c6df7d00d9
...
512bd7737a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
512bd7737a | ||
|
|
4407f71d1f |
2 changed files with 38 additions and 39 deletions
|
|
@ -7,5 +7,5 @@
|
|||
"cmd_addcommand": ["addcommand"],
|
||||
"cmd_listcommands": ["listcommands", "list"],
|
||||
"cmd_roll": ["roll", "r"],
|
||||
"cmd_rotation": ["rotation"]
|
||||
"cmd_speedrotation": ["speedrotation"]
|
||||
}
|
||||
|
|
|
|||
73
methods.py
73
methods.py
|
|
@ -1,9 +1,8 @@
|
|||
#methods.py
|
||||
|
||||
#Imports.
|
||||
import os, json, discord, random, math
|
||||
import os, json, discord, random, math, datetime
|
||||
from dotenv import load_dotenv
|
||||
import datetime
|
||||
|
||||
#Load .env file.
|
||||
load_dotenv()
|
||||
|
|
@ -125,42 +124,11 @@ async def cmd_roll(ctx, inputValue, sign = None, addition = None):
|
|||
except ValueError as e:
|
||||
await ctx.send(f"Invalid input - {e}.")
|
||||
|
||||
########################################################
|
||||
### INTERNAL METHODS - ALL METHODS MUST BE LOWERCASE ###
|
||||
########################################################
|
||||
|
||||
#Loads commands into variable.
|
||||
def loadcommands(filename):
|
||||
if not os.path.exists(filename):
|
||||
with open(filename, "w", encoding="utf-8") as file:
|
||||
json.dump({}, file) # Create an empty JSON file
|
||||
|
||||
with open(filename, "r", encoding="utf-8") as file:
|
||||
return json.load(file)
|
||||
|
||||
#Loads points into variable.
|
||||
def loadpoints():
|
||||
if not os.path.exists("points.json"):
|
||||
with open("points.json", "w", encoding="utf-8") as file:
|
||||
json.dump({}, file) # Create an empty JSON file
|
||||
|
||||
with open("points.json", "r", encoding="utf-8") as file:
|
||||
return json.load(file)
|
||||
|
||||
# Saves points to the points.json file.
|
||||
def savepoints(points_data):
|
||||
with open("points.json", "w", encoding="utf-8") as file:
|
||||
json.dump(points_data, file, indent=4)
|
||||
|
||||
#Rolls die for cmd_roll
|
||||
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):
|
||||
#@bot.command(name='speedrotation')
|
||||
async def cmd_speedrotation(ctx):
|
||||
# Get today's date
|
||||
today = datetime.date.today() # For this example, assume July 24, 2025
|
||||
|
||||
|
|
@ -193,9 +161,40 @@ async def cmd_rotation(ctx):
|
|||
|
||||
# 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')}**."
|
||||
f"Speed is currently in **Week {current_week}** ({status}).\n"
|
||||
f"Speed will be back to working at the office on **{next_week3_monday.strftime('%B %d, %Y')}**."
|
||||
)
|
||||
|
||||
# Send the response
|
||||
await ctx.send(response)
|
||||
|
||||
########################################################
|
||||
### INTERNAL METHODS - ALL METHODS MUST BE LOWERCASE ###
|
||||
########################################################
|
||||
|
||||
#Loads commands into variable.
|
||||
def loadcommands(filename):
|
||||
if not os.path.exists(filename):
|
||||
with open(filename, "w", encoding="utf-8") as file:
|
||||
json.dump({}, file) # Create an empty JSON file
|
||||
|
||||
with open(filename, "r", encoding="utf-8") as file:
|
||||
return json.load(file)
|
||||
|
||||
#Loads points into variable.
|
||||
def loadpoints():
|
||||
if not os.path.exists("points.json"):
|
||||
with open("points.json", "w", encoding="utf-8") as file:
|
||||
json.dump({}, file) # Create an empty JSON file
|
||||
|
||||
with open("points.json", "r", encoding="utf-8") as file:
|
||||
return json.load(file)
|
||||
|
||||
# Saves points to the points.json file.
|
||||
def savepoints(points_data):
|
||||
with open("points.json", "w", encoding="utf-8") as file:
|
||||
json.dump(points_data, file, indent=4)
|
||||
|
||||
#Rolls die for cmd_roll
|
||||
def rolldie(sides):
|
||||
return random.randint(1, sides)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue