Browse Source

starting the warning command and added the check for mod or admin

tags/v1.3.0
roxie 6 years ago
parent
commit
d26755ddc0
3 changed files with 24 additions and 2 deletions
  1. +13
    -0
      checks.py
  2. +7
    -2
      cogs/admin.py
  3. +4
    -0
      config/server_config.py

+ 13
- 0
checks.py View File

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


+ 7
- 2
cogs/admin.py View File

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





+ 4
- 0
config/server_config.py View File

@@ -40,6 +40,10 @@ class ServerConfig():
"0": {},
"1": {}
},
"admin":{
"warnings":{
}
},
"gss":{
"log_channel": "",
"required_days": "",

Loading…
Cancel
Save