Skip to content

Basic Hooks#

This module contains all the basic built-in hooks contained in arc.

Note

Any function that takes a Context as it's sole parameter and returns either None or a HookResult is a valid hook.

bot_has_permissions #

bot_has_permissions(perms: Permissions) -> Callable[[Context[Any]], HookResult]

A pre-execution hook that aborts the execution of a command if the bot is missing the specified permissions in the channel the command was invoked in.

PARAMETER DESCRIPTION
perms

The permissions to check for.

TYPE: Permissions

RAISES DESCRIPTION
GuildOnlyError

If the command is invoked outside of a guild.

BotMissingPermissionsError

If the bot is missing some of the specified permissions.

Example

@arc.with_hook(arc.bot_has_permissions(hikari.Permissions.MANAGE_CHANNELS | hikari.Permissions.MANAGE_GUILD))
You can combine permissions with the bitwise OR operator (|).

Note

This hook requires the command to be invoked in a guild, and implies the guild_only hook.

dm_only #

dm_only(ctx: Context[Any]) -> HookResult

A pre-execution hook that aborts the execution of a command if it is invoked outside of a DM.

Example
@arc.with_hook(arc.dm_only)
RAISES DESCRIPTION
DMOnlyError

If the command is invoked outside of a DM.

guild_only #

guild_only(ctx: Context[Any]) -> HookResult

A pre-execution hook that aborts the execution of a command if it is invoked outside of a guild.

Example
@arc.with_hook(arc.guild_only)
RAISES DESCRIPTION
GuildOnlyError

If the command is invoked outside of a guild.

has_permissions #

has_permissions(perms: Permissions) -> Callable[[Context[Any]], HookResult]

A pre-execution hook that aborts the execution of a command if the invoker is missing the specified permissions in the channel the command was invoked in.

PARAMETER DESCRIPTION
perms

The permissions to check for.

TYPE: Permissions

RAISES DESCRIPTION
GuildOnlyError

If the command is invoked outside of a guild.

InvokerMissingPermissionsError

If the invoker is missing some of the specified permissions.

Example

@arc.with_hook(arc.has_permissions(hikari.Permissions.MANAGE_CHANNELS | hikari.Permissions.MANAGE_GUILD))
You can combine permissions with the bitwise OR operator (|).

Note

This hook requires the command to be invoked in a guild, and implies the guild_only hook.

owner_only #

owner_only(ctx: Context[Any]) -> HookResult

A pre-execution hook that aborts the execution of a command if it is invoked by a non-owner.

Example
@arc.with_hook(arc.owner_only)
RAISES DESCRIPTION
NotOwnerError

If the command is invoked by a non-owner.