From b65254c2cca9a5e9d55eab6117080fde041e0e1b Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Wed, 3 Aug 2022 20:03:48 -0400 Subject: [PATCH] Runtime error fixes. --- cogs/post_highscores/__init__.py | 8 ++++---- data/guild.py | 2 ++ utilities/utils.py | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cogs/post_highscores/__init__.py b/cogs/post_highscores/__init__.py index 177bf8e..601ed0b 100644 --- a/cogs/post_highscores/__init__.py +++ b/cogs/post_highscores/__init__.py @@ -27,16 +27,16 @@ class PostHighscores(commands.Cog, name="Post Highscores"): ?post-scores ``` """ - highscore_channel_id = highscores_data.get_guild(ctx.guild.id).highscore_channel - print(f"Printing out highscores information in channel {highscore_channel_id}") - channel = ctx.guild.get_channel(highscore_channel_id) + guild = highscores_data.get_guild(ctx.guild.id) + print(f"Printing out highscores information in channel {guild.highscore_channel}") + channel = ctx.guild.get_channel(guild.highscore_channel) error_response = "Registered Highscores channel does not exist or was never registered. " error_response += 'Register with "?register" command.' assert channel is not None, await ctx.send(error_response) for table in highscores_data.get_guild(ctx.guild.id).tables: - message: nextcord.Message = await send_highscore_message(channel, table, ctx.guild.id) + message: nextcord.Message = await send_highscore_message(channel, guild, table) await message.edit(view=SubmissionCreateButton(self.bot)) diff --git a/data/guild.py b/data/guild.py index ddb90ac..a106d33 100644 --- a/data/guild.py +++ b/data/guild.py @@ -96,6 +96,7 @@ class Guild: Returns: int: highscore size """ + return self._highscore_size @highscore_size.setter def highscore_size(self, size: int) -> None: @@ -108,6 +109,7 @@ class Guild: Returns: _type_: _description_ """ + self._highscore_size = size @property def submission_channel(self) -> int: diff --git a/utilities/utils.py b/utilities/utils.py index a0b532c..ca20af9 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -37,9 +37,10 @@ def format_highscore_message(guild: Guild, table: Table) -> str: for category in table.categories: if len(category.scores) > i: # pad username to max length. - username: str = category.scores[i].user.ljust(guild.username_length, " ") + # have to convert category.scores into list to make it subscriptable. no idea why. + username: str = list(category.scores)[i].user.ljust(guild.username_length, " ") - score: str = category.scores[i].get_str() + score: str = list(category.scores)[i].get_str() # pad score to correct length # MM:SS.ms is 7 characters long @@ -110,7 +111,7 @@ async def submit_score( score (Score): Score to submit """ - table.get_category(category).add_score(score) + category.add_score(score) # edit message print(f"Editting message {guild.highscore_channel}")