Happens daily starting 3 days before election end.
This commit is contained in:
@@ -3,7 +3,7 @@ Contains the election cycle class
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
@@ -140,6 +140,8 @@ class ElectionCycle:
|
|||||||
await self.election_start_action()
|
await self.election_start_action()
|
||||||
elif today.date() == self.voting_start.date():
|
elif today.date() == self.voting_start.date():
|
||||||
await self.voting_start_action()
|
await self.voting_start_action()
|
||||||
|
elif (self.voting_end - timedelta(3)).date() <= today.date() < self.voting_end.date():
|
||||||
|
await self.election_reminder()
|
||||||
elif today.date() == self.voting_end.date():
|
elif today.date() == self.voting_end.date():
|
||||||
await self.voting_end_action()
|
await self.voting_end_action()
|
||||||
elif today.date() == self.highcouncil_election_start.date():
|
elif today.date() == self.highcouncil_election_start.date():
|
||||||
@@ -273,3 +275,15 @@ class ElectionCycle:
|
|||||||
ElectionInformation.ElectionCycle == get_election_cycle_name(self.config)
|
ElectionInformation.ElectionCycle == get_election_cycle_name(self.config)
|
||||||
)
|
)
|
||||||
return session.scalar(stmt)
|
return session.scalar(stmt)
|
||||||
|
|
||||||
|
async def election_reminder(self) -> None:
|
||||||
|
"""
|
||||||
|
Sends a message to general chat reminder clan about election.
|
||||||
|
"""
|
||||||
|
|
||||||
|
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().ElectionChannel}> to cast your vote!"
|
||||||
|
|
||||||
|
await general.send(content=message)
|
||||||
|
|||||||
@@ -87,3 +87,15 @@ class TestCog(commands.Cog, name="Test commands."):
|
|||||||
config: DakinyConfig = self.bot.config
|
config: DakinyConfig = self.bot.config
|
||||||
cycle = ElectionCycle(get_current_cycle(config), config, self.bot.get_guild(config.params.guild_id))
|
cycle = ElectionCycle(get_current_cycle(config), config, self.bot.get_guild(config.params.guild_id))
|
||||||
await cycle.voting_end_action()
|
await cycle.voting_end_action()
|
||||||
|
|
||||||
|
@test.subcommand()
|
||||||
|
async def election_reminder(self, interaction: nextcord.Interaction):
|
||||||
|
config: DakinyConfig = self.bot.config
|
||||||
|
cycle = ElectionCycle(get_current_cycle(config), config, self.bot.get_guild(config.params.guild_id))
|
||||||
|
await cycle.election_reminder()
|
||||||
|
|
||||||
|
@test.subcommand()
|
||||||
|
async def daily(self, interaction: nextcord.Interaction):
|
||||||
|
config: DakinyConfig = self.bot.config
|
||||||
|
cycle = ElectionCycle(get_current_cycle(config), config, self.bot.get_guild(config.params.guild_id))
|
||||||
|
await cycle.check_date()
|
||||||
|
|||||||
Reference in New Issue
Block a user