Predicate command check for devs
This commit is contained in:
parent
7201d6c8c8
commit
11e6021817
2 changed files with 14 additions and 7 deletions
|
@ -17,7 +17,7 @@ class OwnerCog(commands.Cog):
|
||||||
self.admins = get_config().admins
|
self.admins = get_config().admins
|
||||||
|
|
||||||
@commands.command(name="load", hidden=True)
|
@commands.command(name="load", hidden=True)
|
||||||
@commands.check(user_is_bot_admin)
|
@user_is_bot_admin()
|
||||||
async def _load_cog(self, ctx, *, cog: str):
|
async def _load_cog(self, ctx, *, cog: str):
|
||||||
info = await self.bot.application_info()
|
info = await self.bot.application_info()
|
||||||
if (
|
if (
|
||||||
|
@ -36,7 +36,7 @@ class OwnerCog(commands.Cog):
|
||||||
await ctx.send("I'm afraid I can't let you do that")
|
await ctx.send("I'm afraid I can't let you do that")
|
||||||
|
|
||||||
@commands.command(name="unload", hidden=True)
|
@commands.command(name="unload", hidden=True)
|
||||||
@commands.check(user_is_bot_admin)
|
@user_is_bot_admin()
|
||||||
async def _unload_cog(self, ctx, *, cog: str):
|
async def _unload_cog(self, ctx, *, cog: str):
|
||||||
if cog == "jarvis.cogs.owner":
|
if cog == "jarvis.cogs.owner":
|
||||||
await ctx.send("Cannot unload `owner` cog")
|
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")
|
await ctx.send("I'm afraid I can't let you do that")
|
||||||
|
|
||||||
@commands.command(name="reload", hidden=True)
|
@commands.command(name="reload", hidden=True)
|
||||||
@commands.check(user_is_bot_admin)
|
@user_is_bot_admin()
|
||||||
async def _cog_reload(self, ctx, *, cog: str):
|
async def _cog_reload(self, ctx, *, cog: str):
|
||||||
if cog == "jarvis.cogs.owner":
|
if cog == "jarvis.cogs.owner":
|
||||||
await ctx.send("Cannot reload `owner` cog")
|
await ctx.send("Cannot reload `owner` cog")
|
||||||
|
@ -90,7 +90,7 @@ class OwnerCog(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
@_system.command(name="restart", hidden=True)
|
@_system.command(name="restart", hidden=True)
|
||||||
@commands.check(user_is_bot_admin)
|
@user_is_bot_admin()
|
||||||
async def _restart(self, ctx):
|
async def _restart(self, ctx):
|
||||||
info = await self.bot.application_info()
|
info = await self.bot.application_info()
|
||||||
if (
|
if (
|
||||||
|
@ -113,7 +113,7 @@ class OwnerCog(commands.Cog):
|
||||||
await ctx.send("I'm afraid I can't let you do that")
|
await ctx.send("I'm afraid I can't let you do that")
|
||||||
|
|
||||||
@_system.command(name="update", hidden=True)
|
@_system.command(name="update", hidden=True)
|
||||||
@commands.check(user_is_bot_admin)
|
@user_is_bot_admin()
|
||||||
async def _update(self, ctx):
|
async def _update(self, ctx):
|
||||||
info = await self.bot.application_info()
|
info = await self.bot.application_info()
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -88,5 +88,12 @@ def get_repo_hash():
|
||||||
return repo.head.object.hexsha
|
return repo.head.object.hexsha
|
||||||
|
|
||||||
|
|
||||||
def user_is_bot_admin(ctx):
|
def user_is_bot_admin():
|
||||||
return ctx.author.id in jarvis.config.get_config().admins
|
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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue