lightbulb.prefab.checks¶
- exception BotMissingRequiredPermissions(missing: Permissions, actual: Permissions)[source]¶
Exception raised when the bot is missing one or more required permissions.
- actual: Permissions¶
The permissions the bot has.
- missing: Permissions¶
The permissions the bot is missing.
- exception MissingRequiredPermission(missing: Permissions, actual: Permissions)[source]¶
Exception raised when the user invoking the command is missing one or more required permissions.
- actual: Permissions¶
The permissions the user has.
- missing: Permissions¶
The permissions the user is missing.
- exception MissingRequiredRoles(role_ids: Sequence[Snowflake | int])[source]¶
Exception raised when the user invoking the command is missing one or more required roles.
- exception NotOwner[source]¶
Exception raised when a user that does not own the bot attempts to invoke a protected command.
- bot_has_permissions(permissions: Permissions, /, *, fail_in_dm: bool = True) ExecutionHook [source]¶
Creates a hook that checks whether the bot has all the given permissions. The created hook raises
BotMissingRequiredPermissions
when it fails. This hook is run during theCHECKS
execution step.- Parameters:
permissions – The permissions that the bot should have.
fail_in_dm – Whether this hook should fail if the command is invoked within a DM. Defaults to
True
.
- Returns:
The created hook.
Example
class YourCommand( ..., hooks=[lightbulb.prefab.bot_has_permissions(hikari.Permissions.ADMINISTRATOR)] ): ...
- has_permissions(permissions: Permissions, /, *, fail_in_dm: bool = True) ExecutionHook [source]¶
Creates a hook that checks whether the user invoking the command has all the given permissions. The created hook raises
MissingRequiredPermissions
when it fails. This hook is run during theCHECKS
execution step.- Parameters:
permissions – The permissions that the user should have.
fail_in_dm – Whether this hook should fail if the command is invoked within a DM. Defaults to
True
.
- Returns:
The created hook.
Example
class YourCommand( ..., hooks=[lightbulb.prefab.has_permissions(hikari.Permissions.ADMINISTRATOR)] ): ...
- has_roles(*role_ids: Snowflake | int | Iterable[Snowflake | int], mode: Literal['all', 'any'] = 'all', fail_in_dm: bool = True) ExecutionHook [source]¶
Creates a hook that checks whether the user invoking the command has a correct subset of the given roles.
- Parameters:
*role_ids – The IDs of the role(s) that the user should have.
mode – Whether the user is required to have all the given roles, or any subset of them.
fail_in_dm – Whether this hook should fail if the command is invoked within a DM. Defaults to
True
.
- Returns:
The created hook.
Example
class YourCommand( ..., hooks=[lightbulb.prefab.has_roles(123, 456, 789, mode="any")] ): ...