Start work on vote selection. Modal does not work.
build_develop / build (push) Successful in 1m25s

This commit is contained in:
2023-11-02 17:26:05 -04:00
parent e7bd608017
commit 626cca8b81
4 changed files with 58 additions and 2 deletions
+52
View File
@@ -0,0 +1,52 @@
"""
Contains various views to be used while voting. Controls the logic when performing the vote.
"""
import nextcord
from nextcord import SelectOption
from sqlalchemy import select
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
class VoteModal(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):
super().__init__(
"Nomination",
timeout=5 * 60, # 5 minutes
)
self.list = nextcord.ui.StringSelect(
min_values=1,
max_values=1,
options=[SelectOption(label="one"), SelectOption(label="two"), SelectOption(label="three")],
)
self.add_item(self.list)
class VoteView(nextcord.ui.View):
"""
The button to press to start your nomination.
"""
def __init__(self):
super().__init__(timeout=None)
@nextcord.ui.button(label="Vote", style=nextcord.ButtonStyle.primary, custom_id="vote")
async def vote(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
"""
TODO
Args:
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
await interaction.response.send_modal(VoteModal())