diff --git a/cogs/post_highscores/__init__.py b/cogs/post_highscores/__init__.py index eb6e12a..25cf120 100644 --- a/cogs/post_highscores/__init__.py +++ b/cogs/post_highscores/__init__.py @@ -4,6 +4,8 @@ Bot command to post the highscores from nextcord.ext import commands import highscores # pylint: disable=import-error +from utils import data_storage # pylint: disable=import-error +from utils import message_formatter # pylint: disable=import-error class PostHighscores(commands.Cog, name="Post Highscores"): @@ -27,14 +29,23 @@ class PostHighscores(commands.Cog, name="Post Highscores"): f"Printing out highscores information in channel {channel_id}") channel = self.bot.get_channel(channel_id) for boss in highscores.highscores_config["bosses"]: - print(boss) - boss_name = boss["boss"] - highscore_string = f"**{boss_name}**" - await channel.send(highscore_string) + highscore_string = message_formatter.format_boss_highscore( + boss) + message = await channel.send(highscore_string) + message_id = message.id + + # check if there is a dict for the boss in the highscores data + if not boss["boss"] in highscores.highscores_data: + highscores.highscores_data[boss["boss"]] = {} + + highscores.highscores_data[boss["boss"] + ]["message_id"] = message_id else: response = "Highscores channel is not registered. Register with \"?register\" command." await ctx.send(response) + data_storage.save_highscores_data(highscores.highscores_data) + # This function will be called when this extension is loaded. # It is necessary to add these functions to the bot. diff --git a/highscores_config.json b/highscores_config.json index e89f7f6..e43291e 100755 --- a/highscores_config.json +++ b/highscores_config.json @@ -76,10 +76,6 @@ "boss": "Helwyr", "hardmode": "true" }, - { - "boss": "IM Compiling", - "hardmode": "true" - }, { "boss": "Kalphite King", "hardmode": "false" @@ -193,7 +189,7 @@ }, { "category": "Kill Time", - "hardmore": true, + "hardmode": true, "ascending": true }, { diff --git a/utils/message_formatter.py b/utils/message_formatter.py index 76cfdf1..0833d35 100644 --- a/utils/message_formatter.py +++ b/utils/message_formatter.py @@ -12,19 +12,20 @@ def format_boss_highscore(boss): @return the formatted string """ boss_name = boss["boss"] - ret_string = f"**{boss_name}**/n" + ret_string = f"**{boss_name}**\n" # Gather all categories and add to string for category in highscores.highscores_config["categories"]: category_name = category["category"] ret_string += f"{category_name}\t\t" + ret_string += "\n" highscore_size = highscores.highscores_config["highscore_size"] # list rankings - for x in range(highscore_size): + for i in range(highscore_size): for category in highscores.highscores_config["categories"]: - ret_string += f"{x}: (name here)\t\t" + ret_string += f"{i+1}: (name here)\t\t" ret_string += "\n" # if boss is hardmode, repeat above for hardmode applicable categories @@ -36,7 +37,9 @@ def format_boss_highscore(boss): ret_string += "\n" - for x in range(highscore_size): + for i in range(highscore_size): for category in highscores.highscores_config["categories"]: - ret_string += f"{x}: (name here)\t\t" + if category["hardmode"]: + ret_string += f"{i+1}: (name here)\t\t" ret_string += "\n" + return ret_string