Updated all table data accesses to have table as part of access.

This commit is contained in:
alwayscompiling
2022-07-22 21:30:46 -04:00
parent 307ef86493
commit d0131b1044
5 changed files with 8 additions and 8 deletions
+1
View File
@@ -43,6 +43,7 @@ class PostHighscores(commands.Cog, name="Post Highscores"):
message: nextcord.Message = await send_highscore_message(channel, boss)
await message.edit(view=SubmissionCreateButton(self.bot))
# Saving in case new message was sent.
save_highscores_data(highscores_data)
-1
View File
@@ -5,7 +5,6 @@ Bot command to submit a score
from nextcord.ext import commands
from highscores import highscores_data # pylint: disable=import-error
from utilities.utils import submit_score # pylint: disable=import-error
from .verification_view import VerificationView
+1 -1
View File
@@ -55,7 +55,7 @@ def get_submission_embed(userid: int) -> nextcord.Embed:
def category_select_options(boss_name: str) -> "list[nextcord.SelectOption]":
"""Returns list of categories for a given boss."""
options: "list[nextcord.SelectOption]" = []
boss_dict = highscores_data[boss_name]
boss_dict = highscores_data["tables"][boss_name]
for category in boss_dict["categories"].items():
options.append(nextcord.SelectOption(label=category[0]))
+2 -2
View File
@@ -30,12 +30,12 @@ def open_highscores_data():
data = {"highscore_channel_id": -1, "verification_channel_id": -1, "username_length": 12}
config: dict = open_highscores_config()
for boss, categories in config["highscore_table"].items():
data[boss] = {"message_id": 0}
data["tables"][boss] = {"message_id": 0}
boss_categories = {}
for category in categories: # pylint: disable=unused-variable
rank_list = []
boss_categories[category] = rank_list
data[boss]["categories"] = boss_categories
data["tables"][boss]["categories"] = boss_categories
return data
+4 -4
View File
@@ -16,7 +16,7 @@ def format_highscore_message(boss_name: str):
@return the formatted string
"""
ret_string = f"**{boss_name}**\n```"
boss_data = highscores_data[boss_name]
boss_data = highscores_data["tables"][boss_name]
# Gather all categories and add to string
for key, value in boss_data["categories"].items():
@@ -58,7 +58,7 @@ async def send_highscore_message(channel, boss_name: str) -> nextcord.Message:
"""
highscore_string = format_highscore_message(boss_name)
message_id = highscores_data[boss_name]["message_id"]
message_id = highscores_data["tables"][boss_name]["message_id"]
try:
message: nextcord.Message = await channel.fetch_message(message_id)
await message.edit(content=highscore_string)
@@ -66,7 +66,7 @@ async def send_highscore_message(channel, boss_name: str) -> nextcord.Message:
# message doesn't exist.
message: nextcord.Message = await channel.send(highscore_string)
message_id = message.id
highscores_data[boss_name]["message_id"] = message_id
highscores_data["tables"][boss_name]["message_id"] = message_id
# save message -> boss_name in message_map
highscores_message_map[str(message_id)] = boss_name
@@ -102,7 +102,7 @@ async def submit_score(
score_tuple = (user, int(score))
sort_index = 1
scores: "list[tuple]" = highscores_data[boss_name]["categories"][category]
scores: "list[tuple]" = highscores_data["tables"][boss_name]["categories"][category]
# if user is in an existing tuple, delete it.
users_scores: "list[tuple]" = [score_tuple]