Updated files in classes directory to use new configs. Ensured usages are updated.

This commit is contained in:
2024-09-03 15:57:50 -04:00
parent 2244765d87
commit 3b289e74c8
8 changed files with 78 additions and 109 deletions
+7 -12
View File
@@ -1,7 +1,7 @@
"""Contains various views to be used in the nomination process."""
import nextcord
from DakinySettings import DakinySettings
from DakinySettings import settings
from database_setup.sql_data_classes import CouncilMembers, engine
from nextcord.interactions import Interaction
from sqlalchemy import select
@@ -18,7 +18,6 @@ class NominateModal(nextcord.ui.Modal):
def __init__(
self,
config: DakinySettings,
usr_id: int,
usr_nominated: bool, # noqa: FBT001
speech_content: str,
@@ -28,7 +27,6 @@ class NominateModal(nextcord.ui.Modal):
timeout=5 * 60, # 5 minutes
)
self.usr_id: int = usr_id
self.config: DakinySettings = config
self.usr_nominated = usr_nominated
self.speech = nextcord.ui.TextInput(
@@ -50,7 +48,7 @@ class NominateModal(nextcord.ui.Modal):
"""
speech = decorate_nomination(interaction.user.id, self.speech.value)
election_name = get_election_name(self.config)
election_name = get_election_name(settings)
with Session(engine) as session:
if not self.usr_nominated:
@@ -79,9 +77,8 @@ class NominateModal(nextcord.ui.Modal):
class NominateView(nextcord.ui.View):
"""The button to press to start your nomination."""
def __init__(self, config: DakinySettings, guild: nextcord.Guild):
def __init__(self, guild: nextcord.Guild):
super().__init__(timeout=None)
self.config: DakinySettings = config
self.guild: nextcord.Guild = guild
@nextcord.ui.button(
@@ -101,14 +98,14 @@ class NominateView(nextcord.ui.View):
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce members only
if self.guild.get_role(self.config.params.clan_member_role_id) not in interaction.user.roles:
if self.guild.get_role(settings.role_ids.clan_member) not in interaction.user.roles:
await interaction.response.send_message(
f"You must have the <@&{self.config.params.clan_member_role_id}> role to vote.",
f"You must have the <@&{settings.role_ids.clan_member}> role to vote.",
ephemeral=True,
)
return
election_name = get_election_name(self.config)
election_name = get_election_name(settings)
usr_nominated = False
speech_content = ""
with Session(engine) as session:
@@ -123,6 +120,4 @@ class NominateView(nextcord.ui.View):
msg = await interaction.channel.fetch_message(obj.SpeechMsgId)
speech_content = msg.content.split(NOMINEE_SPLITTER)[1]
await interaction.response.send_modal(
NominateModal(self.config, interaction.user.id, usr_nominated, speech_content)
)
await interaction.response.send_modal(NominateModal(interaction.user.id, usr_nominated, speech_content))