diff --git a/cogs/message_listener/__init__.py b/cogs/message_listener/__init__.py index da7d7d3..3cfa07b 100644 --- a/cogs/message_listener/__init__.py +++ b/cogs/message_listener/__init__.py @@ -43,7 +43,9 @@ class SubmissionListener(commands.Cog, name="Message Listener"): files=[await attch.to_file() for attch in message.attachments], ) elif state == SubmissionState.NAME and message.content: - submission_objects[message.author.id]["username"] = message.content[:12] + submission_objects[message.author.id]["username"] = message.content[ + : highscores_data["username_length"] + ] embed = get_submission_embed(message.author.id) await submission_message.edit( embed=embed, diff --git a/cogs/submission/submission_views.py b/cogs/submission/submission_views.py index 301a2e9..6918a08 100644 --- a/cogs/submission/submission_views.py +++ b/cogs/submission/submission_views.py @@ -201,7 +201,9 @@ class SubmissionCreateButton(nextcord.ui.View): "boss_name": boss_name, "score": "", "category": "", - "username": interaction.user.display_name.split("|")[0][:12], + "username": interaction.user.display_name.split("|")[0][ + : highscores_data["username_length"] + ], } embed = get_submission_embed(interaction.user.id) diff --git a/utilities/data_storage.py b/utilities/data_storage.py index 7f06c94..d29ea49 100644 --- a/utilities/data_storage.py +++ b/utilities/data_storage.py @@ -28,7 +28,7 @@ def open_highscores_data(): data = json.load(file) else: # create the json object - data = {"highscore_channel_id": -1, "verification_channel_id": -1} + data = {"highscore_channel_id": -1, "verification_channel_id": -1, "username_length": 12} config: dict = open_highscores_config() for boss, categories in config["highscore_table"].items(): data[boss] = {"message_id": 0} diff --git a/utilities/utils.py b/utilities/utils.py index df5de74..8162a3a 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -77,9 +77,9 @@ async def submit_score( boss_category_config = highscores_config["categories"][category] - # capping to 12 characters because runescape names are 12 characters long. # Splitting on pipe. My discord has multiple names on account split by pipe. - user = user.split("|")[0][:12] + # 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:")