From e9c83361245164590953b9f284d2542fd831cb7f Mon Sep 17 00:00:00 2001 From: imcompiling Date: Wed, 19 Mar 2025 11:39:26 -0400 Subject: [PATCH] Add module that will support open raid. Add test command. --- off_cooldown_bot/cogs/commands/test.py | 41 +++++++++++++++++++++ off_cooldown_bot/open_raid.py | 49 ++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 off_cooldown_bot/cogs/commands/test.py create mode 100644 off_cooldown_bot/open_raid.py diff --git a/off_cooldown_bot/cogs/commands/test.py b/off_cooldown_bot/cogs/commands/test.py new file mode 100644 index 0000000..6599700 --- /dev/null +++ b/off_cooldown_bot/cogs/commands/test.py @@ -0,0 +1,41 @@ +"""Commands for testing.""" + +import nextcord +from nextcord.ext import application_checks, commands + +from off_cooldown_bot.open_raid import OpenRaid +from off_cooldown_bot.utils import GUILDS + +ME = 206602713511886849 + + +def is_me(): # noqa: ANN201 + """Predicate that makes sure only I can run the test commands.""" + + def predicate(interaction: nextcord.Interaction) -> bool: + return interaction.user.id == ME + + return application_checks.check(predicate) + + +class TestCog(commands.Cog, name="Test commands."): + """Class holds commands for testing.""" + + def __init__(self, bot: commands.Bot) -> None: + self.bot: commands.Bot = bot + + @nextcord.slash_command(guild_ids=GUILDS) + async def test(self, interaction: nextcord.Interaction) -> None: + """Parent slash command for help. Never called.""" + + @test.subcommand() + @is_me() + async def election_start(self, interaction: nextcord.Interaction) -> None: + """ + Force starts election. + + Args: + interaction (nextcord.Interaction): Interaction with the message. + + """ + await interaction.response.send_message("Starting an open raid.", view=OpenRaid()) diff --git a/off_cooldown_bot/open_raid.py b/off_cooldown_bot/open_raid.py new file mode 100644 index 0000000..6af30ec --- /dev/null +++ b/off_cooldown_bot/open_raid.py @@ -0,0 +1,49 @@ +"""Contains functions for open raid sign-ups.""" + +import nextcord + + +class OpenRaid(nextcord.ui.View): + """Class defines view for buttons on an open raid schedule message.""" + + def __init__(self) -> None: + super().__init__(timeout=None, auto_defer=True) + + @nextcord.ui.button(label="Tank", style=nextcord.ButtonStyle.blurple) + async def tank(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: + """ + Signs a user up as a tank. + + Removes them if they are already signed up. + + Args: + button (nextcord.ui.Button): Unneeded. + interaction (nextcord.Interaction): Interaction with command. + + """ + + @nextcord.ui.button(label="Healer", style=nextcord.ButtonStyle.green) + async def healer(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: + """ + Signs a user up as a healer. + + Removes them if they are already signed up. + + Args: + button (nextcord.ui.Button): Unneeded. + interaction (nextcord.Interaction): Interaction with command. + + """ + + @nextcord.ui.button(label="DPS", style=nextcord.ButtonStyle.red) + async def dps(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: + """ + Signs a user up as dps. + + Removes them if they are already signed up. + + Args: + button (nextcord.ui.Button): Unneeded. + interaction (nextcord.Interaction): Interaction with command. + + """