Skip to content

Message command

MessageCommand #

Bases: ContextMenuCommand

Represents an application command for message'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 ReverseTextCommand(MessageCommand):
    def __init__(self) -> None:
        super().__init__(name="Reverse", is_dm_enabled=True)

    async def callback(self, context: InteractionContext, message: Message) -> None:
        await context.create_response(message.content[::-1])

callback async #

callback(context: InteractionContext, message: Message) -> None

A callback of the command.

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

Raises: