Users have to implement manually a check to verify if a user performing a command has the required power level. Since it's a common pattern, we should implement a check for that in checks.py.
Proposed API
def has_power_level(level: int) -> Callable:
async def _has_power_level(ctx: Context) -> bool:
...
def wrapper(cmd: Command) -> Command:
cmd.check(_has_power_level)
Example
from matrix.checks import is_admin
@has_power_level(100)
@bot.command()
async def kick(ctx, user: str) -> None:
Before opening a PR
- Write unit tests
- Run
mypy
- Run
pytest tests/
- Run
black .
Users have to implement manually a check to verify if a user performing a command has the required power level. Since it's a common pattern, we should implement a check for that in
checks.py.Proposed API
Example
Before opening a PR
mypypytest tests/black .