core.check

Module Contents

Functions

acl(ctx: guilded.ext.commands.Context) → bool

ACL check function.

version(major: int, minor: int, micro: Optional[int] = None, reply: bool = True) → Optional[Callable]

Specify minimal guilded.py version

core.check.acl(ctx: guilded.ext.commands.Context) bool

ACL check function.

Parameters

ctx – The command context.

Returns

The ACL result.

If the invocating user is bot owner, the access is always allowed. To disallow the invocation in DMs (e.g. the function uses ctx.guild without checking and handling the error state), use @commands.guild_only().

Note

Because guilded.py’s Bot method is_owner() is a coroutine, we have to access the data directly, instead of loading them dynamically from the API endpoint. The owner_id/ owner_ids argument may be None: that’s the reason lemon.py refreshes it on each on_ready() event in the main file.

If the context is in the DMs, access is always denied, because the ACL is tied to guild IDs.

The command may be disabled globally (by setting guild_id to 0). In that case False is returned.

Then a database lookup is performed. If the command rule is not found, access is denied.

If the rule has user override (explicit allow, explicit deny), this override is returned, and no additional checks are performed.

If the user has no roles, the default permission is returned.

User’s roles are traversed from the top to the bottom. When the first role with mapping to ACL group is found, the search is stopped; if the role isn’t mapped to ACL group, the search continues with lower role.

If the highest ACL-mapped role contains ACL information (e.g. MOD allow), this information is returned. If the group isn’t present in this rule, its parent is looked up and used in comparison – and so on, until decision can be made.

If none of user’s roles are found, the default permission is returned.

To use the check function, import it and include it as decorator:

1from core import acl, utils
2
3...
4
5@commands.check(acl.check)
6@commands.command()
7async def repeat(self, ctx, *, input: str):
8    await ctx.reply(utils.Text.sanitise(input, escape=False))

Note

See the ACL database tables at database.acl.

See the command API at modules.base.acl.module.ACL.

core.check.version(major: int, minor: int, micro: Optional[int] = None, reply: bool = True) Optional[Callable]

Specify minimal guilded.py version

Parameters
  • major – minimum major version

  • minor – minimum minor version of the specified major version

  • micro – optional minimum micro version of that major version

  • reply – flag controls if user receives reply

Returns

function to be called or None on wrong version