You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4KB

  1. from discord.ext import commands
  2. import load_config
  3. from config.server_config import ServerConfig
  4. def is_owner_or_admin():
  5. def predicate(ctx):
  6. if ctx.author.id == load_config.owner:
  7. return True
  8. else:
  9. for role in ctx.author.roles:
  10. if role.id in ServerConfig().load_config()[str(ctx.guild.id)]["perm_roles"]["admin"]:
  11. return True
  12. return False
  13. return commands.check(predicate)
  14. def is_admin_or_mod():
  15. def predicate(ctx):
  16. if ctx.message.author.id == load_config.owner:
  17. return True
  18. else:
  19. admin_roles = ServerConfig().load_config()[str(ctx.guild.id)]["perm_roles"]["admin"]
  20. mod_roles = ServerConfig().load_config()[str(ctx.guild.id)]["perm_roles"]["mod"]
  21. for role in ctx.message.author.roles:
  22. if role.id in mod_roles or role.id in admin_roles:
  23. return True
  24. return False
  25. return commands.check(predicate)
  26. def nsfw_predicate(ctx):
  27. nsfw = ServerConfig().load_config()[str(ctx.guild.id)]["nsfw"]
  28. if not nsfw["channels"] and nsfw["enabled"]:
  29. return nsfw["enabled"] == 1
  30. elif nsfw["enabled"] and nsfw["channels"]:
  31. return ctx.channel.id in nsfw["channels"]
  32. else:
  33. return False
  34. def is_nfsw_enabled():
  35. return commands.check(lambda ctx: nsfw_predicate(ctx))
  36. def isnt_anal():
  37. 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"])