Skip to content

Commit

Permalink
Add new command to ping a cj team from their team channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLovering committed Sep 1, 2023
1 parent 5006072 commit 0169ca7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bot/exts/code_jams/_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,22 @@ async def unpin(self, ctx: commands.Context, message: discord.Message | None = N
"""Lets Code Jam Participants to unpin messages in their team channels."""
await pin_flow(ctx, PIN_ALLOWED_ROLES, self.bot.code_jam_mgmt_api, message, True)

@codejam.command("ping")
@commands.has_any_role(Roles.admins, Roles.events_lead, Roles.code_jam_event_team, Roles.code_jam_participants)
@in_code_jam_category(_creation_utils.CATEGORY_NAME)
async def ping_codejam_team(self, ctx: commands.Context) -> None:
"""Ping the team role for the channel this command is ran in."""
team_resp = await self.bot.code_jam_mgmt_api.get(
"teams/find",
params={"name": ctx.channel.name.replace("-", " ")} # Discord channels have hyphens, CJMS has spaces.
)
role_id = team_resp.get("discord_role_id")
if not role_id:
log.error("Failed to find '%s' in CJMS.", ctx.channel.name)
await ctx.send("Failed to find team role id in database.")
return
await ctx.send(f"<@&{role_id}>")

@staticmethod
def jam_categories(guild: Guild) -> list[discord.CategoryChannel]:
"""Get all the code jam team categories."""
Expand Down

0 comments on commit 0169ca7

Please sign in to comment.