@@ -17,6 +17,19 @@ def is_owner_or_admin(): | |||
return False | |||
return commands.check(predicate) | |||
def is_admin_or_mod(): | |||
def predicate(ctx): | |||
if ctx.message.author.id == load_config.owner: | |||
return True | |||
else: | |||
admin_roles = ServerConfig().load_config()[ctx.message.server.id]["perm_roles"]["admin"] | |||
mod_roles = ServerConfig().load_config()[ctx.message.server.id]["perm_roles"]["mod"] | |||
for role in ctx.message.author.roles: | |||
if role.id in mod_roles or role.id in admin_roles: | |||
return True | |||
return False | |||
return commands.check(predicate) | |||
def is_nfsw_enabled(): | |||
return commands.check(lambda ctx: ServerConfig().load_config()[ctx.message.server.id]["nsfw"]["enabled"] == 1) | |||
@@ -35,7 +35,7 @@ class Admin(): | |||
pass | |||
@checks.not_pm() | |||
@checks.is_owner_or_admin() | |||
@checks.is_admin_or_mod() | |||
@bot.command(pass_context=True) | |||
async def slowmode(self, ctx, time): | |||
if time == "off" and self.slow_mode: # Turn Slow Mode off | |||
@@ -58,7 +58,7 @@ class Admin(): | |||
pass | |||
@checks.is_owner_or_admin() | |||
@checks.is_admin_or_mod() | |||
@bot.command(pass_context=True) | |||
async def emojiuse(self, ctx, emoji, *args): | |||
# TODO: Add check that emoji is an emoji | |||
@@ -138,6 +138,11 @@ class Admin(): | |||
return await self.bot.say("{} has been used {} time(s) in the last month. That's {}/day.".format(emoji, amount, useperday)) | |||
@checks.is_admin_or_mod() | |||
@bot.command(pass_context=True) | |||
async def warn(self, ctx, user: discord.User = None): | |||
pass | |||
@@ -40,6 +40,10 @@ class ServerConfig(): | |||
"0": {}, | |||
"1": {} | |||
}, | |||
"admin":{ | |||
"warnings":{ | |||
} | |||
}, | |||
"gss":{ | |||
"log_channel": "", | |||
"required_days": "", |