Browse Source

Converted over the checks file so it checks the new settings objects.

tags/v1.5.0
Roxie Gibson 6 years ago
parent
commit
c0cb0271c4
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      Roxbot/checks.py

+ 6
- 6
Roxbot/checks.py View File

from discord.ext import commands from discord.ext import commands
from Roxbot import load_config from Roxbot import load_config
from Roxbot.settings.guild_settings import ServerConfig
from Roxbot.settings import guild_settings as gs


def is_owner_or_admin(): def is_owner_or_admin():
def predicate(ctx): def predicate(ctx):
return True return True
else: else:
for role in ctx.author.roles: for role in ctx.author.roles:
if role.id in ServerConfig().load_config()[str(ctx.guild.id)]["perm_roles"]["admin"]:
if role.id in gs.get(ctx.guild).perm_roles["admin"]:
return True return True
return False return False
return commands.check(predicate) return commands.check(predicate)
if ctx.message.author.id == load_config.owner: if ctx.message.author.id == load_config.owner:
return True return True
else: else:
admin_roles = ServerConfig().load_config()[str(ctx.guild.id)]["perm_roles"]["admin"]
mod_roles = ServerConfig().load_config()[str(ctx.guild.id)]["perm_roles"]["mod"]
admin_roles = gs.get(ctx.guild).perm_roles["admin"]
mod_roles = gs.get(ctx.guild).perm_roles["mod"]
for role in ctx.author.roles: for role in ctx.author.roles:
if role.id in mod_roles or role.id in admin_roles: if role.id in mod_roles or role.id in admin_roles:
return True return True
return commands.check(predicate) return commands.check(predicate)


def nsfw_predicate(ctx): def nsfw_predicate(ctx):
nsfw = ServerConfig().load_config()[str(ctx.guild.id)]["nsfw"]
nsfw = gs.get(ctx.guild).nsfw
if not nsfw["channels"] and nsfw["enabled"]: if not nsfw["channels"] and nsfw["enabled"]:
return nsfw["enabled"] == 1 return nsfw["enabled"] == 1
elif nsfw["enabled"] and nsfw["channels"]: elif nsfw["enabled"] and nsfw["channels"]:
return commands.check(lambda ctx: nsfw_predicate(ctx)) return commands.check(lambda ctx: nsfw_predicate(ctx))


def isnt_anal(): def isnt_anal():
return commands.check(lambda ctx: ServerConfig().load_config()[str(ctx.guild.id)]["is_anal"]["y/n"] and nsfw_predicate(ctx) or not ServerConfig().load_config()[str(ctx.guild.id)]["is_anal"]["y/n"])
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"])

Loading…
Cancel
Save