Correct submission listener usage of HighscoresData.
This commit is contained in:
@@ -23,24 +23,24 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
async def on_message(self, message: nextcord.Message):
|
||||
"""Listener for message creation. Adds score and attachments to submission."""
|
||||
guild_id = message.guild.id
|
||||
guild_data = highscores_data[str(guild_id)]
|
||||
if message.author.id in submission_objects:
|
||||
message_id = submission_objects[message.author.id]["message_id"]
|
||||
submission_channel_id = highscores_data.get_guild_submission_channel(guild_id)
|
||||
submission_message: nextcord.Message = (
|
||||
await self.bot.get_guild(guild_id)
|
||||
.get_channel(guild_data["submission_channel_id"])
|
||||
.get_channel(submission_channel_id)
|
||||
.fetch_message(message_id)
|
||||
)
|
||||
|
||||
# need check if correct user and correct channel
|
||||
if message.channel.id == guild_data["submission_channel_id"]:
|
||||
if message.channel.id == submission_channel_id:
|
||||
state = submission_objects[message.author.id]["submission_state"]
|
||||
if state == SubmissionState.SCORE and message.content:
|
||||
|
||||
# check with regex if score matches correctly
|
||||
is_time_record = highscores_config["categories"][
|
||||
is_time_record = highscores_data.get_config_time_record(
|
||||
submission_objects[message.author.id]["category"]
|
||||
]["is_time_record"]
|
||||
)
|
||||
|
||||
time_regex = re.search(
|
||||
"^([0-9]{1,2}:)?[0-9]{2}(\.[0-9])?$", # pylint: disable=anomalous-backslash-in-string
|
||||
@@ -77,7 +77,7 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
)
|
||||
elif state == SubmissionState.NAME and message.content:
|
||||
submission_objects[message.author.id]["username"] = message.content[
|
||||
: guild_data["username_length"]
|
||||
: highscores_data.get_guild_username_length(guild_id)
|
||||
]
|
||||
embed = get_submission_embed(message.author.id)
|
||||
await submission_message.edit(
|
||||
|
||||
@@ -122,6 +122,15 @@ class HighscoresData:
|
||||
"""
|
||||
return self._config["highscore_size"]
|
||||
|
||||
def get_config_time_record(self, category: str) -> bool:
|
||||
"""
|
||||
Tells if the category is a time record
|
||||
|
||||
@param category: category name to retrieve from.
|
||||
@returns: bool indicating time record or not.
|
||||
"""
|
||||
return self._config["categories"][category]["is_time_record"]
|
||||
|
||||
def get_guilds(self) -> "list[int]":
|
||||
"""
|
||||
Gets a list of guilds tracked by data
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ def format_highscore_message(boss_name: str, guild_id: int):
|
||||
|
||||
# pad score to correct length
|
||||
# MM:SS.ms is 7 characters long
|
||||
if highscores_data.get_config_is_category_time_record(key):
|
||||
if highscores_data.get_config_time_record(key):
|
||||
# if there are single digit minutes, add a space for formatting.
|
||||
if score.find(":") and len(score.split(":", maxsplit=1)[0]) < 2:
|
||||
score = " " + score
|
||||
|
||||
Reference in New Issue
Block a user