Predicate command check for devs

This commit is contained in:
Zeva Rose 2021-06-29 20:27:18 -06:00
parent 7201d6c8c8
commit 11e6021817
2 changed files with 14 additions and 7 deletions

View file

@ -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 (

View file

@ -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)