Compare commits

...
2 changed files with 12 additions and 15 deletions
+4 -5
View File
@@ -61,12 +61,11 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
score = message.content
if is_time_record:
# standardize time score format.
# add colon if its not there
# strip leading 0s and colon
# then add colon if its not there
score = score.lstrip("0:")
if score.find(":") == -1:
score = "00:" + score
# add a 0 if there isn't 2 digits before a colon
elif len(score.split(":", maxsplit=1)[0]) < 2:
score = "0" + score
score = "0:" + score
submission_objects[message.author.id]["score"] = score
embed = get_submission_embed(message.author.id)
+8 -10
View File
@@ -36,13 +36,16 @@ def format_highscore_message(boss_name: str, guild_data: dict):
username: str = score_pair[0].ljust(guild_data["username_length"], " ")
score: str = str(score_pair[1])
# pad score to correct length
# MM:SS.ms is 7 characters long
if highscores_config["categories"][key]["is_time_record"]:
# pad score to correct length
# MM:SS.ms is 7 characters long
score = score.ljust(7, " ")
# if there are single digit minutes, add a space for formatting.
if score.find(":") and len(score.split(":", maxsplit=1)[0]) < 2:
score = " " + score
else:
score = score.rjust(7, " ")
line_str = f"{i+1}: {username} - "
ret_string += line_str + score.rjust(26 - len(line_str) - 1) + " "
ret_string += f"{i+1}: {username} - {score}".ljust(26, " ")
else:
ret_string += f"{i+1}: submit your score".ljust(26, " ")
ret_string += "\n"
@@ -144,11 +147,6 @@ async def submit_score(
reverse=not boss_category_config["ascending"],
)
# enforce highscore size
while len(scores) > highscores_config["highscore_size"]:
scores.pop()
guild_data["tables"][boss_name]["categories"][category] = scores
# edit message
highscore_channel_id = guild_data["highscore_channel_id"]
print(f"Editting message {highscore_channel_id}")