Move formatting to when score is retrieved.
This commit is contained in:
@@ -54,7 +54,16 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
embed = submission_message.embeds[0]
|
||||
embed.add_field(name="Error", value="Number record must only be number.")
|
||||
else:
|
||||
submission_objects[message.author.id]["score"] = message.content
|
||||
score = message.content
|
||||
if is_time_record:
|
||||
# standardize time score format.
|
||||
# add colon if its not there
|
||||
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
|
||||
submission_objects[message.author.id]["score"] = score
|
||||
embed = get_submission_embed(message.author.id)
|
||||
|
||||
await submission_message.edit(
|
||||
|
||||
@@ -195,6 +195,7 @@ class SubmissionCreateButton(nextcord.ui.View):
|
||||
|
||||
# a user should only have 1 submission active at once.
|
||||
# submitting with dummy message_id until message created
|
||||
# split username on pipe.
|
||||
submission_objects[interaction.user.id] = {
|
||||
"message_id": 0,
|
||||
"submission_state": SubmissionState.CATEGORY,
|
||||
|
||||
+4
-15
@@ -36,15 +36,11 @@ def format_highscore_message(boss_name: str):
|
||||
username: str = score_pair[0].ljust(highscores_data["username_length"], " ")
|
||||
score: str = str(score_pair[1])
|
||||
|
||||
# standardize time score format.
|
||||
if highscores_config["categories"][key]["is_time_record"]:
|
||||
if score.find(":") == -1:
|
||||
score = "00:" + score
|
||||
elif len(score.split(":", maxsplit=1)[0]) < 2:
|
||||
score = "0" + score
|
||||
if score.find(".") == -1:
|
||||
# insert 2 spaces to make up for period and ms
|
||||
score = score + " "
|
||||
# pad score to correct length
|
||||
# MM:SS.ms is 7 characters long
|
||||
score = score.ljust(7, " ")
|
||||
|
||||
line_str = f"{i+1}: {username} - "
|
||||
ret_string += line_str + score.rjust(26 - len(line_str) - 1) + " "
|
||||
else:
|
||||
@@ -92,13 +88,6 @@ async def submit_score(
|
||||
|
||||
boss_category_config = highscores_config["categories"][category]
|
||||
|
||||
# Splitting on pipe. My discord has multiple names on account split by pipe.
|
||||
# cap length to data defined length.
|
||||
user = user.split("|")[0][: highscores_data["username_length"]]
|
||||
|
||||
# strip leading zeros and colon from score
|
||||
score = score.lstrip("0:")
|
||||
|
||||
# create score tuple for either time or int
|
||||
# define sort index
|
||||
if boss_category_config["is_time_record"]:
|
||||
|
||||
Reference in New Issue
Block a user