diff options
author | 2025-05-03 22:49:04 +0100 | |
---|---|---|
committer | 2025-05-03 22:49:04 +0100 | |
commit | 5cccfa4844f92e7b54df344d23f527b434cf1090 (patch) | |
tree | e69bc443d4e30177ba1692b6b74ea179c47a60dd /arthur | |
parent | Only attempt to get secret value if grafana token is not none (diff) |
Allow helpers to access rule 4
Diffstat (limited to 'arthur')
-rw-r--r-- | arthur/bot.py | 2 | ||||
-rw-r--r-- | arthur/config.py | 1 | ||||
-rw-r--r-- | arthur/exts/fun/devops_rules.py | 9 |
3 files changed, 10 insertions, 2 deletions
diff --git a/arthur/bot.py b/arthur/bot.py index b39ae60..32b0240 100644 --- a/arthur/bot.py +++ b/arthur/bot.py @@ -35,7 +35,7 @@ class KingArthur(BotBase): return CONFIG.devops_role in [r.id for r in ctx.user.roles] return False - if ctx.command.name == "ed": + if ctx.command.name in {"ed", "rules"}: return True if not ctx.guild: diff --git a/arthur/config.py b/arthur/config.py index 0edf30e..7603cf9 100644 --- a/arthur/config.py +++ b/arthur/config.py @@ -25,6 +25,7 @@ class Config( github_org: str = "python-discord" devops_role: int = 409416496733880320 + helpers_role: int = 267630620367257601 guild_id: int = 267624335836053506 devops_channel_id: int = 675756741417369640 devops_vc_id: int = 881573757536329758 diff --git a/arthur/exts/fun/devops_rules.py b/arthur/exts/fun/devops_rules.py index 418c51c..eeb5443 100644 --- a/arthur/exts/fun/devops_rules.py +++ b/arthur/exts/fun/devops_rules.py @@ -1,9 +1,10 @@ """The rules all devops members must follow.""" import discord -from discord.ext.commands import Cog, Context, Greedy, group +from discord.ext.commands import Cog, Context, Greedy, MissingRole, group from arthur.bot import KingArthur +from arthur.config import CONFIG RULES_URL = ( "https://raw.githubusercontent.com/python-discord/infra/main/docs/docs/onboarding/rules.md" @@ -34,6 +35,12 @@ class Rules(Cog): @group(name="rules", aliases=("rule",), invoke_without_command=True) async def rules_group(self, ctx: Context, rules: Greedy[int]) -> None: """List the requested rule(s), or all of them if not defined.""" + role_ids = {r.id for r in ctx.author.roles} + if CONFIG.helpers_role not in role_ids: + raise MissingRole(CONFIG.helpers_role) + if CONFIG.devops_role not in role_ids: + rules = [4] + if rules: output_rules = set(rules) & set(self.rules.keys()) else: |