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 = submission_message.embeds[0]
|
||||||
embed.add_field(name="Error", value="Number record must only be number.")
|
embed.add_field(name="Error", value="Number record must only be number.")
|
||||||
else:
|
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)
|
embed = get_submission_embed(message.author.id)
|
||||||
|
|
||||||
await submission_message.edit(
|
await submission_message.edit(
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ class SubmissionCreateButton(nextcord.ui.View):
|
|||||||
|
|
||||||
# a user should only have 1 submission active at once.
|
# a user should only have 1 submission active at once.
|
||||||
# submitting with dummy message_id until message created
|
# submitting with dummy message_id until message created
|
||||||
|
# split username on pipe.
|
||||||
submission_objects[interaction.user.id] = {
|
submission_objects[interaction.user.id] = {
|
||||||
"message_id": 0,
|
"message_id": 0,
|
||||||
"submission_state": SubmissionState.CATEGORY,
|
"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"], " ")
|
username: str = score_pair[0].ljust(highscores_data["username_length"], " ")
|
||||||
score: str = str(score_pair[1])
|
score: str = str(score_pair[1])
|
||||||
|
|
||||||
# standardize time score format.
|
|
||||||
if highscores_config["categories"][key]["is_time_record"]:
|
if highscores_config["categories"][key]["is_time_record"]:
|
||||||
if score.find(":") == -1:
|
# pad score to correct length
|
||||||
score = "00:" + score
|
# MM:SS.ms is 7 characters long
|
||||||
elif len(score.split(":", maxsplit=1)[0]) < 2:
|
score = score.ljust(7, " ")
|
||||||
score = "0" + score
|
|
||||||
if score.find(".") == -1:
|
|
||||||
# insert 2 spaces to make up for period and ms
|
|
||||||
score = score + " "
|
|
||||||
line_str = f"{i+1}: {username} - "
|
line_str = f"{i+1}: {username} - "
|
||||||
ret_string += line_str + score.rjust(26 - len(line_str) - 1) + " "
|
ret_string += line_str + score.rjust(26 - len(line_str) - 1) + " "
|
||||||
else:
|
else:
|
||||||
@@ -92,13 +88,6 @@ async def submit_score(
|
|||||||
|
|
||||||
boss_category_config = highscores_config["categories"][category]
|
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
|
# create score tuple for either time or int
|
||||||
# define sort index
|
# define sort index
|
||||||
if boss_category_config["is_time_record"]:
|
if boss_category_config["is_time_record"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user