Runtime error fixes.

This commit is contained in:
alwayscompiling
2022-08-03 20:03:48 -04:00
parent 5b3c9ef247
commit b65254c2cc
3 changed files with 10 additions and 7 deletions
+4 -4
View File
@@ -27,16 +27,16 @@ class PostHighscores(commands.Cog, name="Post Highscores"):
?post-scores ?post-scores
``` ```
""" """
highscore_channel_id = highscores_data.get_guild(ctx.guild.id).highscore_channel guild = highscores_data.get_guild(ctx.guild.id)
print(f"Printing out highscores information in channel {highscore_channel_id}") print(f"Printing out highscores information in channel {guild.highscore_channel}")
channel = ctx.guild.get_channel(highscore_channel_id) channel = ctx.guild.get_channel(guild.highscore_channel)
error_response = "Registered Highscores channel does not exist or was never registered. " error_response = "Registered Highscores channel does not exist or was never registered. "
error_response += 'Register with "?register" command.' error_response += 'Register with "?register" command.'
assert channel is not None, await ctx.send(error_response) assert channel is not None, await ctx.send(error_response)
for table in highscores_data.get_guild(ctx.guild.id).tables: 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)) await message.edit(view=SubmissionCreateButton(self.bot))
+2
View File
@@ -96,6 +96,7 @@ class Guild:
Returns: Returns:
int: highscore size int: highscore size
""" """
return self._highscore_size
@highscore_size.setter @highscore_size.setter
def highscore_size(self, size: int) -> None: def highscore_size(self, size: int) -> None:
@@ -108,6 +109,7 @@ class Guild:
Returns: Returns:
_type_: _description_ _type_: _description_
""" """
self._highscore_size = size
@property @property
def submission_channel(self) -> int: def submission_channel(self) -> int:
+4 -3
View File
@@ -37,9 +37,10 @@ def format_highscore_message(guild: Guild, table: Table) -> str:
for category in table.categories: for category in table.categories:
if len(category.scores) > i: if len(category.scores) > i:
# pad username to max length. # 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 # pad score to correct length
# MM:SS.ms is 7 characters long # MM:SS.ms is 7 characters long
@@ -110,7 +111,7 @@ async def submit_score(
score (Score): Score to submit score (Score): Score to submit
""" """
table.get_category(category).add_score(score) category.add_score(score)
# edit message # edit message
print(f"Editting message {guild.highscore_channel}") print(f"Editting message {guild.highscore_channel}")