@@ -1,8 +1,21 @@
|
||||
"""
|
||||
Contains the MessageBuilder class.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from config import DakinyConfig
|
||||
|
||||
|
||||
class MessageBuilder:
|
||||
"""
|
||||
Contains all the announcements that the bot will send regarding elections.
|
||||
"""
|
||||
|
||||
def __init__(self, config: DakinyConfig, cycle: int) -> None:
|
||||
self.config = config
|
||||
self.cycle = cycle
|
||||
|
||||
def get_vote_start(self) -> str:
|
||||
"""
|
||||
Builds the voting start message out of template and configurations.
|
||||
@@ -11,17 +24,35 @@ class MessageBuilder:
|
||||
str: Message to send
|
||||
"""
|
||||
|
||||
message = "<@&{{clan_member_id}}>, it's time to vote for clan council.\
|
||||
\
|
||||
React with <:Rank_Admin:479008185240518656> to vote.\
|
||||
Voting ends next Wednesday , {{voting_end_date}}.\
|
||||
Announcement of the results to whole clan will happen April 6th.\
|
||||
\
|
||||
After a candidate receives 3 votes, their spot is secured in the new council, but you can still vote for them to show your support.\
|
||||
\
|
||||
**Just a reminder:** only the people listed below are eligible to vote, and each clan member may **only vote for one person**. Votes from guests, diplomats, or allies will be annulled. Votes for multiple candidates from the same person will not be counted. \
|
||||
\
|
||||
RS3 Clan Members\
|
||||
vote_end = self.get_datetime(self.config.election_cycles[self.cycle].voting_end)
|
||||
|
||||
message = f"====================\n\
|
||||
<@&{self.config.params.clan_member_role_id}>, it's time to vote for clan council.\n\n\
|
||||
React with <:{self.config.params.voting_emote_id}:> to vote. \
|
||||
Voting ends next Wednesday , {vote_end.date()}. \
|
||||
Announcement of the results to whole clan will happen {vote_end.date()}.\n\n\
|
||||
After a candidate receives 3 votes, their spot is secured in the new council, \
|
||||
but you can still vote for them to show your support.\n\n\
|
||||
**Just a reminder:** only the people listed below are eligible to vote, and each \
|
||||
clan member may **only vote for one person**. Votes from guests, diplomats, or allies \
|
||||
will be annulled. Votes for multiple candidates from the same person will not be counted. \n\n\
|
||||
RS3 Clan Members\n\
|
||||
OSRS Clan Members"
|
||||
|
||||
return message
|
||||
|
||||
def get_datetime(self, day: str) -> datetime:
|
||||
"""
|
||||
Takes in a string month and day and returns a datetime object of that Month/Day this year.
|
||||
|
||||
Args:
|
||||
day (str): Month/Day in that format.
|
||||
|
||||
Returns:
|
||||
datetime: Datetime representation of Month/Day.
|
||||
"""
|
||||
today = datetime.today()
|
||||
month = int(day.split("/")[0])
|
||||
day = int(day.split("/")[1])
|
||||
|
||||
return datetime(today.year, month, day)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
Cog loader. Adds all command cogs to the bot.
|
||||
"""
|
||||
|
||||
from nextcord.ext import commands
|
||||
|
||||
from cogs.commands.test import TestCog
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
def setup(bot: commands.Bot):
|
||||
"""
|
||||
Adds all command classes to bot.
|
||||
"""
|
||||
bot.add_cog(TestCog(bot))
|
||||
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Commands for testing.
|
||||
"""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
from bot_messages.message_builder import MessageBuilder
|
||||
|
||||
|
||||
class TestCog(commands.Cog, name="Test commands."):
|
||||
"""
|
||||
Class holds commands for testing.
|
||||
"""
|
||||
|
||||
def __init__(self, bot) -> None:
|
||||
"""
|
||||
Default constructor for HelpCog class. Does nothing.
|
||||
"""
|
||||
self.bot = bot
|
||||
|
||||
@nextcord.slash_command()
|
||||
async def test(self, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Parent slash command for help. Never called.
|
||||
"""
|
||||
|
||||
@test.subcommand()
|
||||
async def msg_builder(self, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Tests the message builder.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
"""
|
||||
|
||||
msg_bulder = MessageBuilder(self.bot.config, 0)
|
||||
message = msg_bulder.get_vote_start()
|
||||
|
||||
await interaction.channel.send(content=message)
|
||||
@@ -24,7 +24,6 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
||||
"""
|
||||
Starts the loop when bot is ready.
|
||||
"""
|
||||
print("on ready")
|
||||
await self.bot.wait_until_ready()
|
||||
# pylint doesn't recognize that periodic_update_guild_data is subclassed from tasks.loop.
|
||||
await self.do_thing.start() # pylint: disable=no-member
|
||||
|
||||
Reference in New Issue
Block a user