diff --git a/jarvis/cogs/owner.py b/jarvis/cogs/owner.py index 07baa7f..89a83b4 100644 --- a/jarvis/cogs/owner.py +++ b/jarvis/cogs/owner.py @@ -17,7 +17,7 @@ class OwnerCog(commands.Cog): self.admins = get_config().admins @commands.command(name="load", hidden=True) - @commands.check(user_is_bot_admin) + @user_is_bot_admin() async def _load_cog(self, ctx, *, cog: str): info = await self.bot.application_info() if ( @@ -36,7 +36,7 @@ class OwnerCog(commands.Cog): await ctx.send("I'm afraid I can't let you do that") @commands.command(name="unload", hidden=True) - @commands.check(user_is_bot_admin) + @user_is_bot_admin() async def _unload_cog(self, ctx, *, cog: str): if cog == "jarvis.cogs.owner": await ctx.send("Cannot unload `owner` cog") @@ -58,7 +58,7 @@ class OwnerCog(commands.Cog): await ctx.send("I'm afraid I can't let you do that") @commands.command(name="reload", hidden=True) - @commands.check(user_is_bot_admin) + @user_is_bot_admin() async def _cog_reload(self, ctx, *, cog: str): if cog == "jarvis.cogs.owner": await ctx.send("Cannot reload `owner` cog") @@ -90,7 +90,7 @@ class OwnerCog(commands.Cog): ) @_system.command(name="restart", hidden=True) - @commands.check(user_is_bot_admin) + @user_is_bot_admin() async def _restart(self, ctx): info = await self.bot.application_info() if ( @@ -113,7 +113,7 @@ class OwnerCog(commands.Cog): await ctx.send("I'm afraid I can't let you do that") @_system.command(name="update", hidden=True) - @commands.check(user_is_bot_admin) + @user_is_bot_admin() async def _update(self, ctx): info = await self.bot.application_info() if ( diff --git a/jarvis/utils/__init__.py b/jarvis/utils/__init__.py index 7cfcdd6..17ef1ca 100644 --- a/jarvis/utils/__init__.py +++ b/jarvis/utils/__init__.py @@ -88,5 +88,12 @@ def get_repo_hash(): return repo.head.object.hexsha -def user_is_bot_admin(ctx): - return ctx.author.id in jarvis.config.get_config().admins +def user_is_bot_admin(): + def predicate(ctx): + config = jarvis.config.get_config() + if getattr(config, "admins", None): + return ctx.author.id in config.admins + else: + return False + + return commands.check(predicate)