Skip to content

User command

UserCommand #

Bases: ContextMenuCommand

Represents an application command for user's context menu.

Parameters:

  • name (str) –

    The unique name of the command.

  • display_name (LocalizedOr[str] | None, default: None ) –

    A display name of command. Can be localized.

  • guild (SnowflakeishOr[PartialGuild] | UndefinedType, default: UNDEFINED ) –

    Optional guild (server) where the command is available.

  • default_member_permissions (Permissions, default: Permissions.NONE ) –

    The permissions a user must have to use the command by default.

  • is_dm_enabled (bool, default: False ) –

    Whether the command can be used in direct messages.

  • is_nsfw (bool, default: False ) –

    Indicates whether the command is age-restricted.

Example
class HelloUserCommand(UserCommand):
    def __init__(self) -> None:
        super().__init__(name="Hello to")

    async def callback(self, context: InteractionContext, target: InteractionMember | User) -> None:
        await context.create_response(f"Hi, {target.mention}!")

callback async #

callback(context: InteractionContext, target: InteractionMember | PartialUser) -> None

A callback of the command.

Meant to override this method to set the callback to the command.

Raises: