Pass config along so that nominate can add to database with election cycle name.
This commit is contained in:
@@ -170,7 +170,7 @@ class ElectionCycle:
|
||||
for index, message in enumerate(messages):
|
||||
# if last item, add the nominate button
|
||||
if index + 1 == len(messages):
|
||||
await election_channel.send(message, view=NominateView())
|
||||
await election_channel.send(message, view=NominateView(self.config))
|
||||
else:
|
||||
await election_channel.send(message)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import nextcord
|
||||
from nextcord.interactions import Interaction
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from config import DakinyConfig
|
||||
from database_setup.sql_data_classes import CouncilMembers, engine
|
||||
from utils import get_election_cycle_name
|
||||
|
||||
@@ -15,7 +16,7 @@ class NominateModal(nextcord.ui.Modal):
|
||||
Modal for nominating oneself. User writes a speech and then the callback sends the speech into the correct channel.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, config):
|
||||
super().__init__(
|
||||
"Nomination",
|
||||
timeout=5 * 60, # 5 minutes
|
||||
@@ -29,6 +30,7 @@ class NominateModal(nextcord.ui.Modal):
|
||||
max_length=1500,
|
||||
)
|
||||
self.add_item(self.speech)
|
||||
self.config: DakinyConfig = config
|
||||
|
||||
async def callback(self, interaction: Interaction) -> None:
|
||||
"""
|
||||
@@ -48,9 +50,10 @@ class NominateModal(nextcord.ui.Modal):
|
||||
|
||||
with Session(engine) as session:
|
||||
council_member = CouncilMembers(
|
||||
ElectionCycle=get_election_cycle_name(self.bot.config), MemberId=interaction.user.id
|
||||
ElectionCycle=get_election_cycle_name(self.config), MemberId=interaction.user.id
|
||||
)
|
||||
session.add(council_member)
|
||||
session.commit()
|
||||
|
||||
|
||||
class NominateView(nextcord.ui.View):
|
||||
@@ -58,9 +61,10 @@ class NominateView(nextcord.ui.View):
|
||||
The button to press to start your nomination.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, config):
|
||||
super().__init__(timeout=None)
|
||||
self.config: DakinyConfig = config
|
||||
|
||||
@nextcord.ui.button(label="Nominate Yourself", style=nextcord.ButtonStyle.primary, custom_id="nominate")
|
||||
async def nominate(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
|
||||
await interaction.response.send_modal(NominateModal())
|
||||
await interaction.response.send_modal(NominateModal(self.config))
|
||||
|
||||
Reference in New Issue
Block a user