[V3 Permissions] Don't rely on load order to be consistent (#1760)

* Modifies permissions re #1758

* requested changes in
This commit is contained in:
Michael H
2018-06-02 18:10:40 -04:00
committed by Will
parent 0d193d3e9e
commit 5de5a519c3
2 changed files with 13 additions and 65 deletions

View File

@@ -12,21 +12,10 @@ async def val_if_check_is_valid(*, ctx: commands.Context, check: object, level:
Returns the value from a check if it is valid
"""
# Non staticmethods should not be run without their parent
# class, even if the parent class did not deregister them
if check.__module__ is None:
pass
elif isinstance(check, types.FunctionType):
if (
next(filter(lambda x: check.__module__ == x.__module__, ctx.bot.cogs.values()), None)
is None
):
return None
val = None
# let's not spam the console with improperly made 3rd party checks
try:
if asyncio.iscoroutine(check) or asyncio.iscoroutinefunction(check):
if asyncio.iscoroutinefunction(check):
val = await check(ctx, level=level)
else:
val = check(ctx, level=level)