Get table names from data. Update post scores to use HighscoresData class.
This commit is contained in:
@@ -6,9 +6,7 @@ from nextcord.ext import commands
|
||||
import nextcord
|
||||
|
||||
from cogs.submission.submission_views import SubmissionCreateButton # pylint: disable=import-error
|
||||
from highscores import highscores_config # pylint: disable=import-error
|
||||
from highscores import highscores_data # pylint: disable=import-error
|
||||
from utilities.data_storage import save_highscores_data # pylint: disable=import-error
|
||||
from utilities.utils import send_highscore_message # pylint: disable=import-error
|
||||
|
||||
|
||||
@@ -29,24 +27,18 @@ class PostHighscores(commands.Cog, name="Post Highscores"):
|
||||
?post-scores
|
||||
```
|
||||
"""
|
||||
guild_data = highscores_data[str(ctx.guild.id)]
|
||||
highscore_channel_id = guild_data["highscore_channel_id"]
|
||||
highscore_channel_id = highscores_data.get_guild_channel_id(ctx.guild.id)
|
||||
print(f"Printing out highscores information in channel {highscore_channel_id}")
|
||||
channel = ctx.guild.get_channel(highscore_channel_id)
|
||||
|
||||
error_response = 'Registered Highscores channel does not exist or was never registered. \n\
|
||||
Register with "?register" command.'
|
||||
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 boss, categories in highscores_config[ # pylint: disable=unused-variable
|
||||
"tables"
|
||||
].items():
|
||||
message: nextcord.Message = await send_highscore_message(channel, boss, guild_data)
|
||||
for table in highscores_data.get_table_names(ctx.guild.id):
|
||||
message: nextcord.Message = await send_highscore_message(channel, table, ctx.guild.id)
|
||||
await message.edit(view=SubmissionCreateButton(self.bot))
|
||||
|
||||
# Saving in case new message was sent.
|
||||
save_highscores_data(highscores_data)
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
|
||||
Reference in New Issue
Block a user