Turned on all ruff rules. Formatted all files.
This commit is contained in:
+29
-89
@@ -55,15 +55,9 @@ class ElectionCycle:
|
||||
self.term_end: datetime = get_datetime(self.election_cycle.term_end)
|
||||
self.voting_start: datetime = get_datetime(self.election_cycle.voting_start)
|
||||
self.voting_end: datetime = get_datetime(self.election_cycle.voting_end)
|
||||
self.highcouncil_election_announce: datetime = get_datetime(
|
||||
self.election_cycle.highcouncil_election_announce
|
||||
)
|
||||
self.highcouncil_election_start: datetime = get_datetime(
|
||||
self.election_cycle.highcouncil_election_start
|
||||
)
|
||||
self.highcouncil_election_end: datetime = get_datetime(
|
||||
self.election_cycle.highcouncil_election_end
|
||||
)
|
||||
self.highcouncil_election_announce: datetime = get_datetime(self.election_cycle.highcouncil_election_announce)
|
||||
self.highcouncil_election_start: datetime = get_datetime(self.election_cycle.highcouncil_election_start)
|
||||
self.highcouncil_election_end: datetime = get_datetime(self.election_cycle.highcouncil_election_end)
|
||||
self.guild: nextcord.Guild = guild
|
||||
self.election_over: bool = False
|
||||
|
||||
@@ -76,15 +70,11 @@ class ElectionCycle:
|
||||
long.
|
||||
"""
|
||||
|
||||
with open(
|
||||
f"{TEMPLATES_DIR}/election_announcement.txt", mode="r", encoding="utf8"
|
||||
) as file:
|
||||
with open(f"{TEMPLATES_DIR}/election_announcement.txt", mode="r", encoding="utf8") as file:
|
||||
message = file.read()
|
||||
|
||||
next_election = get_datetime(
|
||||
self.config.election_cycles[
|
||||
(self.cycle + 1) % len(self.config.election_cycles)
|
||||
].election_start
|
||||
self.config.election_cycles[(self.cycle + 1) % len(self.config.election_cycles)].election_start
|
||||
)
|
||||
|
||||
message = message.format(
|
||||
@@ -109,22 +99,14 @@ class ElectionCycle:
|
||||
str: Message to send.
|
||||
"""
|
||||
|
||||
with open(
|
||||
f"{TEMPLATES_DIR}/highcouncil_election.txt", mode="r", encoding="utf8"
|
||||
) as file:
|
||||
with open(f"{TEMPLATES_DIR}/highcouncil_election.txt", mode="r", encoding="utf8") as file:
|
||||
message = file.read()
|
||||
|
||||
return message.format(
|
||||
clan_council_elect_role_id=self.config.params.clan_council_elect_role_id,
|
||||
highcouncil_election_announce=self.highcouncil_election_announce.strftime(
|
||||
"%B %d"
|
||||
),
|
||||
highcouncil_election_start=self.highcouncil_election_start.strftime(
|
||||
"%B %d"
|
||||
),
|
||||
highcouncil_election_end=self.highcouncil_election_end.strftime(
|
||||
"%B %d"
|
||||
),
|
||||
highcouncil_election_announce=self.highcouncil_election_announce.strftime("%B %d"),
|
||||
highcouncil_election_start=self.highcouncil_election_start.strftime("%B %d"),
|
||||
highcouncil_election_end=self.highcouncil_election_end.strftime("%B %d"),
|
||||
term_start=self.term_start.strftime("%B %d"),
|
||||
)
|
||||
|
||||
@@ -136,9 +118,7 @@ class ElectionCycle:
|
||||
str: Message to send.
|
||||
"""
|
||||
|
||||
with open(
|
||||
f"{TEMPLATES_DIR}/highcouncil_vote.txt", mode="r", encoding="utf8"
|
||||
) as file:
|
||||
with open(f"{TEMPLATES_DIR}/highcouncil_vote.txt", mode="r", encoding="utf8") as file:
|
||||
message = file.read()
|
||||
|
||||
return message.format(
|
||||
@@ -156,9 +136,7 @@ class ElectionCycle:
|
||||
|
||||
with open(f"{TEMPLATES_DIR}/vote_start.txt", mode="r", encoding="utf8") as file:
|
||||
message = file.read()
|
||||
vote_end: datetime = get_datetime(
|
||||
self.config.election_cycles[self.cycle].voting_end
|
||||
)
|
||||
vote_end: datetime = get_datetime(self.config.election_cycles[self.cycle].voting_end)
|
||||
|
||||
return message.format(
|
||||
clan_member_id=self.config.params.clan_member_role_id,
|
||||
@@ -177,11 +155,7 @@ class ElectionCycle:
|
||||
await self.election_start_action()
|
||||
elif today.date() == self.voting_start.date():
|
||||
await self.voting_start_action()
|
||||
elif (
|
||||
(self.voting_end - timedelta(3)).date()
|
||||
<= today.date()
|
||||
< self.voting_end.date()
|
||||
):
|
||||
elif (self.voting_end - timedelta(3)).date() <= today.date() < self.voting_end.date():
|
||||
await self.election_reminder()
|
||||
elif today.date() == self.voting_end.date():
|
||||
await self.voting_end_action()
|
||||
@@ -195,16 +169,12 @@ class ElectionCycle:
|
||||
Performs required actions for when the election cycle starts.
|
||||
"""
|
||||
# create new channel for election
|
||||
parent: nextcord.TextChannel = self.guild.get_channel(
|
||||
self.config.params.voting_parent_id
|
||||
)
|
||||
parent: nextcord.TextChannel = self.guild.get_channel(self.config.params.voting_parent_id)
|
||||
quarter_name: str = get_election_name(self.config)
|
||||
|
||||
thread_msg: nextcord.Message = await parent.send(content=quarter_name)
|
||||
|
||||
thread: nextcord.Thread = await parent.create_thread(
|
||||
name=quarter_name, message=thread_msg
|
||||
)
|
||||
thread: nextcord.Thread = await parent.create_thread(name=quarter_name, message=thread_msg)
|
||||
|
||||
# post message announcing election
|
||||
# election start message is returned as an array of string because it is too long. send each string
|
||||
@@ -213,9 +183,7 @@ class ElectionCycle:
|
||||
for index, message in enumerate(messages):
|
||||
# if last item, add the nominate button
|
||||
if index + 1 == len(messages):
|
||||
nominate_msg: nextcord.Message = await thread.send(
|
||||
message, view=NominateView(self.config, self.guild)
|
||||
)
|
||||
nominate_msg: nextcord.Message = await thread.send(message, view=NominateView(self.config, self.guild))
|
||||
else:
|
||||
await thread.send(message)
|
||||
|
||||
@@ -235,9 +203,7 @@ class ElectionCycle:
|
||||
Removes write permission from the general clan member role.
|
||||
"""
|
||||
message = self.build_vote_start()
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(
|
||||
self.get_election_info().ThreadId
|
||||
)
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
||||
await election_thread.send(message)
|
||||
vote_msg = await election_thread.send(
|
||||
build_votes_str(self.config, self.guild),
|
||||
@@ -253,9 +219,7 @@ class ElectionCycle:
|
||||
session.commit()
|
||||
|
||||
thread: nextcord.Thread = self.guild.get_thread(info.ThreadId)
|
||||
nominate_msg: nextcord.Message = await thread.fetch_message(
|
||||
info.CouncilNominationMsgId
|
||||
)
|
||||
nominate_msg: nextcord.Message = await thread.fetch_message(info.CouncilNominationMsgId)
|
||||
await nominate_msg.edit(view=None)
|
||||
|
||||
async def voting_end_action(self) -> None:
|
||||
@@ -264,12 +228,8 @@ class ElectionCycle:
|
||||
"""
|
||||
|
||||
message = self.build_highcouncil_election_announce()
|
||||
council_elect_role: nextcord.Role = self.guild.get_role(
|
||||
self.config.params.clan_council_elect_role_id
|
||||
)
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(
|
||||
self.get_election_info().ThreadId
|
||||
)
|
||||
council_elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
||||
|
||||
nominate_msg: nextcord.Message = await election_thread.send(
|
||||
message, view=NominateHighCouncilView(self.config, self.guild)
|
||||
@@ -279,13 +239,9 @@ class ElectionCycle:
|
||||
|
||||
with Session(engine) as session:
|
||||
# remove vote button from vote message
|
||||
stmt = select(ElectionInformation).where(
|
||||
ElectionInformation.ElectionCycle == election_name
|
||||
)
|
||||
stmt = select(ElectionInformation).where(ElectionInformation.ElectionCycle == election_name)
|
||||
info = session.scalar(stmt)
|
||||
vote_msg: nextcord.Message = await election_thread.fetch_message(
|
||||
info.CouncilVoteMsgId
|
||||
)
|
||||
vote_msg: nextcord.Message = await election_thread.fetch_message(info.CouncilVoteMsgId)
|
||||
await vote_msg.edit(view=None)
|
||||
|
||||
# add the highcouncil nomination message to election information
|
||||
@@ -324,9 +280,7 @@ class ElectionCycle:
|
||||
"""
|
||||
|
||||
message = self.build_highcouncil_vote_start()
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(
|
||||
self.get_election_info().ThreadId
|
||||
)
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
||||
await election_thread.send(message)
|
||||
vote_msg = await election_thread.send(
|
||||
build_highcouncil_votes_str(self.config, self.guild),
|
||||
@@ -342,9 +296,7 @@ class ElectionCycle:
|
||||
session.commit()
|
||||
|
||||
# remove highcouncil nomination view
|
||||
nomination_msg: nextcord.Message = await election_thread.fetch_message(
|
||||
info.HighCouncilNominationMsgId
|
||||
)
|
||||
nomination_msg: nextcord.Message = await election_thread.fetch_message(info.HighCouncilNominationMsgId)
|
||||
await nomination_msg.edit(view=None)
|
||||
|
||||
async def term_start_action(self) -> None:
|
||||
@@ -354,12 +306,8 @@ class ElectionCycle:
|
||||
|
||||
self.election_over = True
|
||||
|
||||
elect_role: nextcord.Role = self.guild.get_role(
|
||||
self.config.params.clan_council_elect_role_id
|
||||
)
|
||||
council_role: nextcord.Role = self.guild.get_role(
|
||||
self.config.params.clan_council_role_id
|
||||
)
|
||||
elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||
council_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_role_id)
|
||||
|
||||
election_cycle = get_election_name(self.config)
|
||||
|
||||
@@ -422,9 +370,7 @@ class ElectionCycle:
|
||||
|
||||
session.commit()
|
||||
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(
|
||||
self.get_election_info().ThreadId
|
||||
)
|
||||
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
||||
|
||||
# clear view from vote message
|
||||
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
||||
@@ -434,15 +380,11 @@ class ElectionCycle:
|
||||
vote_msg: nextcord.Message = await election_thread.fetch_message(vote_msg_id)
|
||||
await vote_msg.edit(view=None)
|
||||
|
||||
highcouncil_msg: str = (
|
||||
f"Congratulations for our high council members!\nClan Leader: <@{cl_winner}>\n"
|
||||
)
|
||||
highcouncil_msg: str = f"Congratulations for our high council members!\nClan Leader: <@{cl_winner}>\n"
|
||||
highcouncil_msg += f"Discord Manager: <@{dm_winner}>"
|
||||
await election_thread.send(highcouncil_msg)
|
||||
|
||||
await election_thread.send(
|
||||
"This election cycle is now over. Thank you everyone for participating!"
|
||||
)
|
||||
await election_thread.send("This election cycle is now over. Thank you everyone for participating!")
|
||||
|
||||
await election_thread.edit(archived=True, locked=True)
|
||||
await edit_clan_council_info(self.guild, self.config)
|
||||
@@ -466,9 +408,7 @@ class ElectionCycle:
|
||||
Sends a message to general chat reminder clan about election.
|
||||
"""
|
||||
|
||||
general: nextcord.TextChannel = self.guild.get_channel(
|
||||
self.config.params.general_channel_id
|
||||
)
|
||||
general: nextcord.TextChannel = self.guild.get_channel(self.config.params.general_channel_id)
|
||||
|
||||
message = f"Reminder to <@&{self.config.params.clan_member_role_id}>! Clan elections are happening! Head over "
|
||||
message += f"to <#{self.get_election_info().ThreadId}> to cast your vote!"
|
||||
|
||||
@@ -74,14 +74,8 @@ class NominateDMModal(nextcord.ui.Modal):
|
||||
council_elect.DiscordManagerSpeechId = msg.id
|
||||
session.commit()
|
||||
else:
|
||||
msg: nextcord.Message = await interaction.channel.fetch_message(
|
||||
council_elect.DiscordManagerSpeechId
|
||||
)
|
||||
await msg.edit(
|
||||
content=decorate_dm_nomination(
|
||||
interaction.user.id, self.speech.value
|
||||
)
|
||||
)
|
||||
msg: nextcord.Message = await interaction.channel.fetch_message(council_elect.DiscordManagerSpeechId)
|
||||
await msg.edit(content=decorate_dm_nomination(interaction.user.id, self.speech.value))
|
||||
|
||||
|
||||
class NominateCLModal(nextcord.ui.Modal):
|
||||
@@ -141,14 +135,8 @@ class NominateCLModal(nextcord.ui.Modal):
|
||||
council_elect.ClanLeaderSpeechId = msg.id
|
||||
session.commit()
|
||||
else:
|
||||
msg: nextcord.Message = await interaction.channel.fetch_message(
|
||||
council_elect.ClanLeaderSpeechId
|
||||
)
|
||||
await msg.edit(
|
||||
content=decorate_cl_nomination(
|
||||
interaction.user.id, self.speech.value
|
||||
)
|
||||
)
|
||||
msg: nextcord.Message = await interaction.channel.fetch_message(council_elect.ClanLeaderSpeechId)
|
||||
await msg.edit(content=decorate_cl_nomination(interaction.user.id, self.speech.value))
|
||||
|
||||
|
||||
class NominateHighCouncilView(nextcord.ui.View):
|
||||
@@ -166,9 +154,7 @@ class NominateHighCouncilView(nextcord.ui.View):
|
||||
style=nextcord.ButtonStyle.primary,
|
||||
custom_id="nominate-dm",
|
||||
)
|
||||
async def nominate_dm(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
) -> None:
|
||||
async def nominate_dm(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
|
||||
"""
|
||||
Gathers previous information about the user if they have already nominated themselves, then launches
|
||||
the nomination modal to get their speech.
|
||||
@@ -179,10 +165,7 @@ class NominateHighCouncilView(nextcord.ui.View):
|
||||
"""
|
||||
|
||||
# enforce council elect only
|
||||
if (
|
||||
self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||
not in interaction.user.roles
|
||||
):
|
||||
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
|
||||
await interaction.response.send_message(
|
||||
f"You must have the <@&{self.config.params.clan_council_elect_role_id}> role to vote.",
|
||||
ephemeral=True,
|
||||
@@ -203,15 +186,11 @@ class NominateHighCouncilView(nextcord.ui.View):
|
||||
# user needs to exist to get here anyways...
|
||||
if obj.DiscordManagerSpeechId is not None:
|
||||
usr_nominated = True
|
||||
msg = await interaction.channel.fetch_message(
|
||||
obj.DiscordManagerSpeechId
|
||||
)
|
||||
msg = await interaction.channel.fetch_message(obj.DiscordManagerSpeechId)
|
||||
speech_content = msg.content.split(NOMINEE_SPLITTER)[1]
|
||||
|
||||
await interaction.response.send_modal(
|
||||
NominateDMModal(
|
||||
self.config, interaction.user.id, usr_nominated, speech_content
|
||||
)
|
||||
NominateDMModal(self.config, interaction.user.id, usr_nominated, speech_content)
|
||||
)
|
||||
|
||||
@nextcord.ui.button(
|
||||
@@ -219,9 +198,7 @@ class NominateHighCouncilView(nextcord.ui.View):
|
||||
style=nextcord.ButtonStyle.primary,
|
||||
custom_id="nominate-cl",
|
||||
)
|
||||
async def nominate_cl(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
) -> None:
|
||||
async def nominate_cl(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
|
||||
"""
|
||||
Gathers previous information about the user if they have already nominated themselves, then launches
|
||||
the nomination modal to get their speech.
|
||||
@@ -232,10 +209,7 @@ class NominateHighCouncilView(nextcord.ui.View):
|
||||
"""
|
||||
|
||||
# enforce council elect only
|
||||
if (
|
||||
self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||
not in interaction.user.roles
|
||||
):
|
||||
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
|
||||
await interaction.response.send_message(
|
||||
f"You must have the <@&{self.config.params.clan_council_elect_role_id}> role to vote.",
|
||||
ephemeral=True,
|
||||
@@ -260,7 +234,5 @@ class NominateHighCouncilView(nextcord.ui.View):
|
||||
speech_content = msg.content.split(NOMINEE_SPLITTER)[1]
|
||||
|
||||
await interaction.response.send_modal(
|
||||
NominateCLModal(
|
||||
self.config, interaction.user.id, usr_nominated, speech_content
|
||||
)
|
||||
NominateCLModal(self.config, interaction.user.id, usr_nominated, speech_content)
|
||||
)
|
||||
|
||||
@@ -74,12 +74,8 @@ class NominateModal(nextcord.ui.Modal):
|
||||
)
|
||||
obj = session.scalar(stmt)
|
||||
|
||||
msg: nextcord.Message = await interaction.channel.fetch_message(
|
||||
obj.SpeechMsgId
|
||||
)
|
||||
await msg.edit(
|
||||
content=decorate_nomination(interaction.user.id, self.speech.value)
|
||||
)
|
||||
msg: nextcord.Message = await interaction.channel.fetch_message(obj.SpeechMsgId)
|
||||
await msg.edit(content=decorate_nomination(interaction.user.id, self.speech.value))
|
||||
|
||||
|
||||
class NominateView(nextcord.ui.View):
|
||||
@@ -97,9 +93,7 @@ class NominateView(nextcord.ui.View):
|
||||
style=nextcord.ButtonStyle.primary,
|
||||
custom_id="nominate",
|
||||
)
|
||||
async def nominate(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
) -> None:
|
||||
async def nominate(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
|
||||
"""
|
||||
Gathers previous information about the user if they have already nominated themselves, then launches
|
||||
the nomination modal to get their speech.
|
||||
@@ -110,10 +104,7 @@ class NominateView(nextcord.ui.View):
|
||||
"""
|
||||
|
||||
# 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(self.config.params.clan_member_role_id) 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.",
|
||||
ephemeral=True,
|
||||
@@ -136,7 +127,5 @@ class NominateView(nextcord.ui.View):
|
||||
speech_content = msg.content.split(NOMINEE_SPLITTER)[1]
|
||||
|
||||
await interaction.response.send_modal(
|
||||
NominateModal(
|
||||
self.config, interaction.user.id, usr_nominated, speech_content
|
||||
)
|
||||
NominateModal(self.config, interaction.user.id, usr_nominated, speech_content)
|
||||
)
|
||||
|
||||
@@ -21,9 +21,7 @@ from utils import VoteType, build_highcouncil_votes_str, get_election_name
|
||||
|
||||
|
||||
class VoteSelect(nextcord.ui.StringSelect):
|
||||
def __init__(
|
||||
self, options: List["SelectOption"], config: DakinyConfig, election_type: str
|
||||
) -> None:
|
||||
def __init__(self, options: List["SelectOption"], config: DakinyConfig, election_type: str) -> None:
|
||||
super().__init__(
|
||||
placeholder="Choose 1",
|
||||
min_values=1,
|
||||
@@ -71,9 +69,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
session.commit()
|
||||
|
||||
vote_message_str = build_highcouncil_votes_str(self.config, interaction.guild)
|
||||
vote_msg: nextcord.Message = await interaction.channel.fetch_message(
|
||||
vote_msg_id
|
||||
)
|
||||
vote_msg: nextcord.Message = await interaction.channel.fetch_message(vote_msg_id)
|
||||
await vote_msg.edit(content=vote_message_str)
|
||||
|
||||
if voted_for is not None:
|
||||
@@ -99,9 +95,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
style=nextcord.ButtonStyle.primary,
|
||||
custom_id="vote-cl",
|
||||
)
|
||||
async def vote_cl(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
) -> None:
|
||||
async def vote_cl(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
|
||||
"""
|
||||
Enforces only council elect vote. Gets election cycle, creates voting
|
||||
options for clan leader (checking if user has voted already),
|
||||
@@ -113,10 +107,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
"""
|
||||
|
||||
# enforce council elect only
|
||||
if (
|
||||
self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||
not in interaction.user.roles
|
||||
):
|
||||
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
|
||||
await interaction.response.send_message(
|
||||
f"You must have the <@&{self.config.params.clan_council_elect_role_id}> role to vote.",
|
||||
ephemeral=True,
|
||||
@@ -162,11 +153,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
)
|
||||
|
||||
view = nextcord.ui.View()
|
||||
view.add_item(
|
||||
VoteSelect(
|
||||
options=options, config=self.config, election_type=VoteType.CLANLEADER
|
||||
)
|
||||
)
|
||||
view.add_item(VoteSelect(options=options, config=self.config, election_type=VoteType.CLANLEADER))
|
||||
|
||||
await interaction.response.send_message(
|
||||
content="Please vote for a Clan Leader!",
|
||||
@@ -179,9 +166,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
style=nextcord.ButtonStyle.primary,
|
||||
custom_id="vote-dm",
|
||||
)
|
||||
async def vote_dm(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
) -> None:
|
||||
async def vote_dm(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None:
|
||||
"""
|
||||
Enforces only council elect vote. Gets election cycle, creates voting
|
||||
options for discord manager (checking if user has voted already),
|
||||
@@ -193,10 +178,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
"""
|
||||
|
||||
# enforce council elect only
|
||||
if (
|
||||
self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||
not in interaction.user.roles
|
||||
):
|
||||
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
|
||||
await interaction.response.send_message(
|
||||
f"You must have the <@&{self.config.params.clan_council_elect_role_id}> role to vote.",
|
||||
ephemeral=True,
|
||||
|
||||
+5
-16
@@ -67,9 +67,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
session.commit()
|
||||
|
||||
vote_message_str = build_votes_str(self.config, interaction.guild)
|
||||
vote_msg: nextcord.Message = await interaction.channel.fetch_message(
|
||||
vote_msg_id
|
||||
)
|
||||
vote_msg: nextcord.Message = await interaction.channel.fetch_message(vote_msg_id)
|
||||
await vote_msg.edit(content=vote_message_str)
|
||||
|
||||
if voted_for is not None:
|
||||
@@ -90,12 +88,8 @@ class VoteView(nextcord.ui.View):
|
||||
self.config = config
|
||||
self.guild = guild
|
||||
|
||||
@nextcord.ui.button(
|
||||
label="Vote", style=nextcord.ButtonStyle.primary, custom_id="vote"
|
||||
)
|
||||
async def vote(
|
||||
self, button: nextcord.ui.Button, interaction: nextcord.Interaction
|
||||
) -> 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:
|
||||
"""
|
||||
Enforces only members vote. Gets election cycle, creates voting options (checking if user has voted already),
|
||||
then sends the voting view.
|
||||
@@ -106,10 +100,7 @@ class VoteView(nextcord.ui.View):
|
||||
"""
|
||||
|
||||
# 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(self.config.params.clan_member_role_id) 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.",
|
||||
ephemeral=True,
|
||||
@@ -127,9 +118,7 @@ class VoteView(nextcord.ui.View):
|
||||
)
|
||||
voted_for = session.scalar(stmt)
|
||||
|
||||
stmt = select(CouncilMembers.MemberId).where(
|
||||
CouncilMembers.ElectionCycle == election
|
||||
)
|
||||
stmt = select(CouncilMembers.MemberId).where(CouncilMembers.ElectionCycle == election)
|
||||
|
||||
options = [
|
||||
SelectOption(
|
||||
|
||||
Reference in New Issue
Block a user