aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2025-07-10 14:16:05 +0100
committerGravatar Joe Banks <[email protected]>2025-07-10 14:17:07 +0100
commit2d721775ace9e2ce4c02c1e5c3b922108e6af4f6 (patch)
tree8cd131d9db3d4f3bd8fba435e2431faa5566e98b
parentAdd new APIs for adding team members (diff)
Add new GitHub extension
-rw-r--r--arthur/exts/github/__init__.py1
-rw-r--r--arthur/exts/github/management.py42
2 files changed, 43 insertions, 0 deletions
diff --git a/arthur/exts/github/__init__.py b/arthur/exts/github/__init__.py
new file mode 100644
index 0000000..78cc904
--- /dev/null
+++ b/arthur/exts/github/__init__.py
@@ -0,0 +1 @@
+"""Utilities for managing the GitHub organisation."""
diff --git a/arthur/exts/github/management.py b/arthur/exts/github/management.py
new file mode 100644
index 0000000..202dd5b
--- /dev/null
+++ b/arthur/exts/github/management.py
@@ -0,0 +1,42 @@
+"""Commands for managing the GitHub organisation and teams."""
+
+from discord.ext.commands import Cog, Context, group
+
+from arthur.apis.github import GitHubException, add_staff_member
+from arthur.bot import KingArthur
+from arthur.config import CONFIG
+
+
+class GitHubManagement(Cog):
+ """Ed is the standard text editor."""
+
+ def __init__(self, bot: KingArthur) -> None:
+ self.bot = bot
+
+ async def cog_check(self, ctx: Context) -> bool:
+ """Check if the user has permission to use this cog."""
+ return (
+ CONFIG.admins_role in [r.id for r in ctx.author.roles]
+ or CONFIG.devops_role in [r.id for r in ctx.author.roles]
+ or await self.bot.is_owner(ctx.author)
+ )
+
+ @group(name="github", invoke_without_command=True)
+ async def github(self, ctx: Context) -> None:
+ """Group of commands for managing the GitHub organisation."""
+ if ctx.invoked_subcommand is None:
+ await ctx.send_help(ctx.command)
+
+ @github.command(name="add")
+ async def add_team_member(self, ctx: Context, username: str) -> None:
+ """Add a user to the default GitHub team."""
+ try:
+ await add_staff_member(username)
+ await ctx.send(f":white_check_mark: Successfully invited {username} to the staff team.")
+ except GitHubException as e:
+ await ctx.send(f":x: Failed to add {username} to the staff team: {e}")
+
+
+async def setup(bot: KingArthur) -> None:
+ """Add cog to bot."""
+ await bot.add_cog(GitHubManagement(bot))