Update submissin cog to new data class. Also clean up import lists.
This commit is contained in:
@@ -9,10 +9,11 @@ import re
|
|||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
import nextcord
|
import nextcord
|
||||||
|
|
||||||
from cogs.submission.submission_views import SubmissionState # pylint: disable=import-error
|
from cogs.submission.submission_views import ( # pylint: disable=import-error
|
||||||
from cogs.submission.submission_views import get_submission_embed # pylint: disable=import-error
|
SubmissionState,
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
get_submission_embed,
|
||||||
from highscores import submission_objects # pylint: disable=import-error
|
)
|
||||||
|
from highscores import highscores_data, submission_objects # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
class SubmissionListener(commands.Cog, name="Message Listener"):
|
class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import nextcord
|
|||||||
from nextcord import Embed
|
from nextcord import Embed
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from highscores import highscores_data # pylint: disable=import-error
|
from highscores import ( # pylint: disable=import-error
|
||||||
from highscores import highscores_message_map # pylint: disable=import-error
|
highscores_data,
|
||||||
from highscores import submission_objects # pylint: disable=import-error
|
highscores_message_map,
|
||||||
|
submission_objects,
|
||||||
|
)
|
||||||
from .verification_view import VerificationView
|
from .verification_view import VerificationView
|
||||||
|
|
||||||
|
|
||||||
@@ -55,9 +57,9 @@ def get_submission_embed(userid: int) -> nextcord.Embed:
|
|||||||
def category_select_options(guild_id: int, boss_name: str) -> "list[nextcord.SelectOption]":
|
def category_select_options(guild_id: int, boss_name: str) -> "list[nextcord.SelectOption]":
|
||||||
"""Returns list of categories for a given boss."""
|
"""Returns list of categories for a given boss."""
|
||||||
options: "list[nextcord.SelectOption]" = []
|
options: "list[nextcord.SelectOption]" = []
|
||||||
category_list = highscores_data.get_table_categories(guild_id, boss_name)
|
category_list = highscores_data.get_guild(guild_id).get_table(boss_name).categories
|
||||||
for category in category_list:
|
for category in category_list:
|
||||||
options.append(nextcord.SelectOption(label=category))
|
options.append(nextcord.SelectOption(label=category.name))
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
@@ -148,9 +150,9 @@ class SubmitButton(nextcord.ui.Button):
|
|||||||
self._bot = bot
|
self._bot = bot
|
||||||
|
|
||||||
async def callback(self, interaction: nextcord.Interaction):
|
async def callback(self, interaction: nextcord.Interaction):
|
||||||
verification_channel_id = highscores_data.get_guild_verification_channel(
|
verification_channel_id = highscores_data.get_guild(
|
||||||
interaction.guild_id
|
interaction.guild_id
|
||||||
)
|
).verification_channel
|
||||||
channel = interaction.guild.get_channel(verification_channel_id)
|
channel = interaction.guild.get_channel(verification_channel_id)
|
||||||
|
|
||||||
error_response = "Registered Verification channel does not exist or was never registered. \
|
error_response = "Registered Verification channel does not exist or was never registered. \
|
||||||
@@ -195,7 +197,7 @@ class SubmissionCreateButton(nextcord.ui.View):
|
|||||||
|
|
||||||
boss_name = highscores_message_map[interaction.guild.id][interaction.message.id]
|
boss_name = highscores_message_map[interaction.guild.id][interaction.message.id]
|
||||||
channel = interaction.guild.get_channel(
|
channel = interaction.guild.get_channel(
|
||||||
highscores_data.get_guild_submission_channel(interaction.guild_id)
|
highscores_data.get_guild(interaction.guild_id).submission_channel
|
||||||
)
|
)
|
||||||
|
|
||||||
# a user should only have 1 submission active at once.
|
# a user should only have 1 submission active at once.
|
||||||
@@ -209,7 +211,7 @@ class SubmissionCreateButton(nextcord.ui.View):
|
|||||||
"score": "",
|
"score": "",
|
||||||
"category": "",
|
"category": "",
|
||||||
"username": interaction.user.display_name.split("|")[0][
|
"username": interaction.user.display_name.split("|")[0][
|
||||||
: highscores_data.get_guild_username_length(interaction.guild_id)
|
: highscores_data.get_guild(interaction.guild_id).username_length
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user