diff options
Diffstat (limited to '')
| -rw-r--r-- | arthur/bot.py | 18 | 
1 files changed, 7 insertions, 11 deletions
| diff --git a/arthur/bot.py b/arthur/bot.py index 8c1dd73..79de985 100644 --- a/arthur/bot.py +++ b/arthur/bot.py @@ -3,13 +3,14 @@  from pathlib import Path  from typing import Any -from discord import Interaction, Member, User +from discord import Interaction, Member  from discord.ext import commands  from kubernetes_asyncio import config  from kubernetes_asyncio.config.kube_config import KUBE_CONFIG_DEFAULT_LOCATION  from pydis_core import BotBase  from sentry_sdk import new_scope +import arthur  from arthur import exts  from arthur.config import CONFIG  from arthur.log import logger @@ -20,12 +21,14 @@ class KingArthur(BotBase):      def __init__(self, *args: list[Any], **kwargs: dict[str, Any]) -> None:          super().__init__(*args, **kwargs) -          self.add_check(self._is_devops) -    @staticmethod -    def _is_devops(ctx: commands.Context | Interaction) -> bool: +    async def _is_devops(self, ctx: commands.Context | Interaction) -> bool:          """Check all commands are executed by authorised personnel.""" +        u = ctx.user if isinstance(ctx, Interaction) else ctx.author +        if await arthur.instance.is_owner(u): +            return True +          if isinstance(ctx, Interaction):              if isinstance(ctx.user, Member):                  return CONFIG.devops_role in [r.id for r in ctx.user.roles] @@ -56,13 +59,6 @@ class KingArthur(BotBase):          await self.load_extension("jishaku")          logger.info("Loaded <red>jishaku</red>") -    async def is_owner(self, user: User | Member) -> bool: -        """Check if the invoker is a bot owner.""" -        if not user.guild: -            return False - -        return CONFIG.devops_role in [r.id for r in user.roles] -      async def on_error(self, event_name: str, *args: Any, **kwargs: Any) -> None:          """Log errors raised in event listeners."""          with new_scope() as scope: | 
