Browse Source

small refactoring to admin and checks that does literally nothing tbh

tags/v1.7.0
Roxie Gibson 6 years ago
parent
commit
7fee1c64cf
2 changed files with 15 additions and 11 deletions
  1. +9
    -3
      Roxbot/checks.py
  2. +6
    -8
      Roxbot/cogs/admin.py

+ 9
- 3
Roxbot/checks.py View File

@@ -1,10 +1,11 @@
from discord.ext import commands
from Roxbot import load_config
from Roxbot.load_config import owner
from Roxbot.settings import guild_settings as gs


def is_owner_or_admin():
def predicate(ctx):
if ctx.author.id == load_config.owner:
if ctx.author.id == owner:
return True
else:
for role in ctx.author.roles:
@@ -13,8 +14,9 @@ def is_owner_or_admin():
return False
return commands.check(predicate)


def _is_admin_or_mod(ctx):
if ctx.message.author.id == load_config.owner:
if ctx.message.author.id == owner:
return True
else:
admin_roles = gs.get(ctx.guild).perm_roles["admin"]
@@ -24,9 +26,11 @@ def _is_admin_or_mod(ctx):
return True
return False


def is_admin_or_mod():
return commands.check(_is_admin_or_mod)


def nsfw_predicate(ctx):
nsfw = gs.get(ctx.guild).nsfw
if not nsfw["channels"] and nsfw["enabled"]:
@@ -36,8 +40,10 @@ def nsfw_predicate(ctx):
else:
return False


def is_nfsw_enabled():
return commands.check(lambda ctx: nsfw_predicate(ctx))


def isnt_anal():
return commands.check(lambda ctx: gs.get(ctx.guild).is_anal["y/n"] and nsfw_predicate(ctx) or not gs.get(ctx.guild).is_anal["y/n"])

+ 6
- 8
Roxbot/cogs/admin.py View File

@@ -5,18 +5,16 @@ from discord.ext import commands
from discord.ext.commands import bot

import Roxbot as roxbot
gs = roxbot.guild_settings
from Roxbot import guild_settings as gs


def _is_admin_or_mod(message): # TODO: Remove this function and find a better solution thank.
def _is_admin_or_mod(message):
if message.author.id == roxbot.owner:
return True
else:
admin_roles = gs.get(message.channel.guild).perm_roles["admin"]
mod_roles = gs.get(message.channel.guild).perm_roles["mod"]
for role in message.author.roles:
if role.id in mod_roles or role.id in admin_roles:
return True
perm_roles = gs.get(message.channel.guild).perm_roles
for role in message.author.roles:
if role.id in perm_roles.get("admin") or role.id in perm_roles.get("mod"):
return True
return False



Loading…
Cancel
Save