Skip to content

Implement /helpop command #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e7dc642
Implement helpop command
MattyTheHacker May 25, 2025
0f8a0c1
minor improvements
MattyTheHacker May 25, 2025
fcfe616
minor improvements
MattyTheHacker May 25, 2025
3eb81a2
fix message
MattyTheHacker May 25, 2025
5a4940f
Update helpop.py
MattyTheHacker May 25, 2025
c0a1ff5
Merge branch 'main' into 16-helpop
MattyTheHacker May 27, 2025
c0fffc6
Merge branch 'main' into 16-helpop
MattyTheHacker May 27, 2025
370afee
Merge main into 16-helpop
cssbhamdev Jun 12, 2025
9855143
Merge main into 16-helpop
cssbhamdev Jun 13, 2025
fdefa34
Merge main into 16-helpop
cssbhamdev Jun 13, 2025
8b83bdb
Merge main into 16-helpop
cssbhamdev Jun 14, 2025
1a6ff75
Allow committee-elect to update actions (and appear in auto-complete)…
Thatsmusic99 Jun 15, 2025
6ff1f66
Merge main into 16-helpop
cssbhamdev Jun 15, 2025
971f323
Merge main into 16-helpop
cssbhamdev Jun 15, 2025
9786e7a
Merge main into 16-helpop
cssbhamdev Jun 15, 2025
93420e7
Merge main into 16-helpop
cssbhamdev Jun 15, 2025
b9acb9d
Merge main into 16-helpop
cssbhamdev Jun 16, 2025
0c1dd93
Merge main into 16-helpop
cssbhamdev Jun 16, 2025
327ad99
Merge main into 16-helpop
cssbhamdev Jun 17, 2025
8612b5d
Merge main into 16-helpop
cssbhamdev Jun 19, 2025
24a561b
Merge main into 16-helpop
cssbhamdev Jun 19, 2025
b364977
Merge main into 16-helpop
cssbhamdev Jun 22, 2025
3d5710a
Merge main into 16-helpop
cssbhamdev Jun 24, 2025
3839394
Merge main into 16-helpop
cssbhamdev Jun 24, 2025
af8b781
Merge main into 16-helpop
cssbhamdev Jun 24, 2025
46219c9
Merge main into 16-helpop
cssbhamdev Jun 25, 2025
d5def6f
Merge main into 16-helpop
cssbhamdev Jun 30, 2025
00ab641
Merge main into 16-helpop
automatic-pr-updater[bot] Jun 30, 2025
3774ac4
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 2, 2025
570231e
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 2, 2025
16f3ac4
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 3, 2025
aa5e47a
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 3, 2025
0a33f87
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 3, 2025
ee6f829
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 4, 2025
2ac1195
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 4, 2025
accd0ee
Merge main into 16-helpop
automatic-pr-updater[bot] Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .edit_message import EditMessageCommandCog
from .everest import EverestCommandCog
from .get_token_authorisation import GetTokenAuthorisationCommandCog
from .helpop import HelpopCommandCog
from .induct import (
EnsureMembersInductedCommandCog,
InductContextCommandsCog,
Expand Down Expand Up @@ -63,6 +64,7 @@
"EnsureMembersInductedCommandCog",
"EverestCommandCog",
"GetTokenAuthorisationCommandCog",
"HelpopCommandCog",
"InductContextCommandsCog",
"InductSendMessageCog",
"InductSlashCommandCog",
Expand Down Expand Up @@ -104,6 +106,7 @@ def setup(bot: "TeXBot") -> None:
EnsureMembersInductedCommandCog,
EverestCommandCog,
GetTokenAuthorisationCommandCog,
HelpopCommandCog,
InductContextCommandsCog,
InductSendMessageCog,
InductSlashCommandCog,
Expand Down
101 changes: 101 additions & 0 deletions cogs/helpop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""Contains cog class for helpop commands."""

import logging
from typing import TYPE_CHECKING

import discord

from utils import CommandChecks, TeXBotBaseCog

if TYPE_CHECKING:
from collections.abc import Sequence
from logging import Logger
from typing import Final

from utils import TeXBotApplicationContext

__all__: "Sequence[str]" = ("HelpopCommandCog",)

logger: "Final[Logger]" = logging.getLogger("TeX-Bot")


class HelpopCommandCog(TeXBotBaseCog):
"""Cog for helpop commands."""

helpop_commands: discord.SlashCommandGroup = discord.SlashCommandGroup(
name="helpop",
description="Commands for creating and managing helpop channels.",
)

@helpop_commands.command(
name="open",
description="Create a private channel with committee.",
)
@CommandChecks.check_interaction_user_in_main_guild
async def open(self, ctx: "TeXBotApplicationContext") -> None:
"""Create a private channel with committee."""
# NOTE: Shortcut accessors are placed at the top of the function, so that the exceptions they raise are displayed before any further errors may be sent
main_guild: discord.Guild = self.bot.main_guild

if isinstance(ctx.user, discord.User):
await self.command_send_error(
ctx=ctx,
message="This command can only be used in the main guild.",
)
return

committee_external_category: discord.CategoryChannel | None = discord.utils.get(
main_guild.categories,
name="Committee - External",
)

if committee_external_category is None:
await self.command_send_error(
ctx=ctx,
message="The required discord category could not be found.",
)
return

new_channel: discord.TextChannel = await main_guild.create_text_channel(
name=f"helpop-{ctx.author.name}",
category=committee_external_category,
reason=f'{ctx.user} used TeX Bot slash-command: "/helpop"',
)

await new_channel.edit(sync_permissions=True)

await new_channel.set_permissions(
target=ctx.user,
read_messages=True,
send_messages=True,
view_channel=True,
)

await new_channel.send(
content=f"Hello {ctx.author.mention}, this is a private channel with the committee"
" to discuss an issue or concern. Please use the `/helpop close` command "
"after the issue is resolved."
)

await ctx.respond(
content=f"Helpop channel created: {new_channel.mention}",
ephemeral=True,
)

@helpop_commands.command(
name="close",
description="Close the helpop channel.",
)
async def close(self, ctx: "TeXBotApplicationContext") -> None:
"""Close the helpop channel."""
if (
not isinstance(ctx.channel, discord.TextChannel)
or "helpop" not in ctx.channel.name
):
await self.command_send_error(
ctx=ctx,
message="This command can only be used in a helpop channel.",
)
return

await ctx.channel.delete()