database.acl¶
Module Contents¶
Classes¶
Permission group. |
|
Permission rule. |
|
User constraint of the |
|
Group constraint of the |
- class database.acl.ACL_group¶
Permission group.
Groups are the connecting interface between Guilded roles and permission rules. They are meant to be organised in a trees:
VERIFIED <id-of-role> BOOSTER <id-of-role> MODERATORS MOD <id-of-role> SUBMOD <id-of-role> GUEST <id-of-role>
Note
See the ACL check function at
core.acl.check().See the command API at
modules.base.acl.module.ACL.- idx¶
- guild_id¶
- name¶
- parent¶
- role_id¶
- rules¶
- dump(self) Dict[str, Union[int, str]]¶
Return object representation as dictionary for easy serialisation.
- static add(guild_id: int, name: str, parent: Optional[str], role_id: Optional[int]) ACL_group¶
Add new permission group.
- Parameters
guild_id – Guild ID.
name – Permission group name.
parent – Name of parent permission group. May be
None.role_id – ID for the Guilded
Role. May beNoneto disable mapping from role to the group.
- Returns
New group.
- save(self)¶
- static get(guild_id: int, name: str) Optional[ACL_group]¶
Get permission group.
- Parameters
guild_id – Guild ID.
name – Name of the permisson group.
- Returns
Found group or
None.
- static get_by_role(guild_id: int, role_id: int) Optional[ACL_group]¶
Get permission group by role ID.
- Parameters
guild_id – Guild ID.
role_id – Role ID.
- Returns
Found group or
None.
- class database.acl.ACL_rule¶
Permission rule.
Each rule holds information about the command, defaults (
TrueorFalse), its guild (as ACL permissions are guild-dependent) and a list of Guilded users and ACL groups.Note
See the ACL check function at
core.acl.check().See the command API at
modules.base.acl.module.ACL.- idx¶
- guild_id¶
- command¶
- default¶
- users¶
- groups¶
- dump(self) Dict[str, Union[int, str, List[Union[int, str]]]]¶
Return object representation as dictionary for easy serialisation.
- static add(guild_id: int, command: str, default: bool) ACL_rule¶
Add new permission rule.
- Parameters
guild_id – Guild ID.
command – Qualified command name (see
qualified_nameattribute).default –
Trueif the command should be usable by anyone by default,Falseotherwise.
- Returns
New rule.
- static get(guild_id: int, command: str) Optional[ACL_rule]¶
Get permission rule.
- Parameters
guild_id – Guild ID.
command – Qualified command name (see
qualified_nameattribute).
- Returns
Found permission rule or
None.
- static get_all(guild_id: int) List[ACL_rule]¶
Get all guild’s rules.
- Parameters
guild_id – Guild ID.
- Returns
List of permission rules.
- static remove(guild_id: int, command: str) int¶
Remove permission rule.
- Parameters
guild_id – Guild ID.
command – Qualified command name (see
qualified_nameattribute).
- Returns
Number of deleted rules, always
0or1.
- static remove_all(guild_id: int) int¶
Remove all permission rules.
- Parameters
guild_id – Guild ID.
- Returns
Number of deleted rules.
- add_group(self, group_name: str, allow: bool) ACL_rule_group¶
Add group constraint to the rule.
- Parameters
group_name – Name of permission group. Must be a group defined in the same guild as the rule.
allow – Whether to allow or deny the permission to given group.
- Returns
Rule group constraint.
- remove_group(self, group_name: str) int¶
Remove group constraint from the rule.
- Parameters
group_name – Name of permission group. Must be a group defined in the same guild as the rule.
- Returns
Number of removed group constraints, always
0or1.
- add_user(self, user_id: int, allow: bool) ACL_rule_user¶
Add user constraint to the rule.
- Parameters
user_id – User ID.
allow – Whether to allow or deny the permission to given user.
- Returns
Rule user constraint.