From 797f8a46aa68751c51dc7b312af2302c1b236918 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Fri, 14 Jul 2023 11:31:52 -0400 Subject: [PATCH] Flushed out election start. Added a file to track what permissions the bot needs. --- classes/election_cycle.py | 18 +++++++++++++++--- cogs/commands/test.py | 12 ++++++++++++ permissions_required.txt | 3 +++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 permissions_required.txt diff --git a/classes/election_cycle.py b/classes/election_cycle.py index 09f4e1d..5d4a9e8 100644 --- a/classes/election_cycle.py +++ b/classes/election_cycle.py @@ -45,7 +45,8 @@ class ElectionCycle: Builds the messages to announce the election is starting. Returns: - list[str]: A list of message contents in the correct order. + list[str]: A list of message contents in the correct order. Must be a string because the message is too + long. """ with open("bot_messages/election_announcement.txt", mode="r", encoding="utf8") as file: @@ -128,8 +129,19 @@ class ElectionCycle: Performs required actions for when the election cycle starts. """ print("election cycle has started") - await self.message_me("election cycle has started") - # TODO get message, input variables, split into multiple messages, send to correct channel. + # create new channel for election + category: nextcord.CategoryChannel = self.bot.get_channel(self.config.params.active_category_id) + quarter_name: str = str(datetime.today().year) + "-" + self.elecion_cycle.name + "-election" + # TODO need to store this id in the sqlite database + election_channel = await category.create_text_channel(quarter_name) + + # post message announcing election + # election start message is returned as an array of string because it is too long. send each string + # individually. + messages = self.build_election_announcement() + + for message in messages: + await election_channel.send(message) async def voting_start_action(self) -> None: """ diff --git a/cogs/commands/test.py b/cogs/commands/test.py index 2d6e032..95bcbbc 100644 --- a/cogs/commands/test.py +++ b/cogs/commands/test.py @@ -41,3 +41,15 @@ class TestCog(commands.Cog, name="Test commands."): # doesn't tell discord that the message was responded to. Is a test command so I don't really care atm. for m in message: await interaction.channel.send(content=m) + + @test.subcommand() + async def election_start(self, interaction: nextcord.Interaction): + """ + idc + + Args: + interaction (nextcord.Interaction): _description_ + """ + + cycle = ElectionCycle(0, self.bot) + await cycle.election_start_action() diff --git a/permissions_required.txt b/permissions_required.txt new file mode 100644 index 0000000..dc1e30b --- /dev/null +++ b/permissions_required.txt @@ -0,0 +1,3 @@ +Discord permissions required for bot to operate: + +manage channels \ No newline at end of file