Skip to content

Context

InteractionContext #

Represents a interaction context.

Attributes:

  • interaction (CommandInteraction | ComponentInteraction) –

    The interaction.

  • bot (GatewayBotAware) –

    The instance of the bot.

  • client (Client) –

    The client.

  • command (AppCommand) –

    Command of interaction.

    Note

    Available only for commands.

  • locale (Any) –

    An any locale object for the interaction.

  • arguments (Dict[str, Any]) –

    Arguments to the interaction.

    Note

    Available only for commands.

channel property #

channel: PartialChannel | None

Channel of the interaction.

guild property #

guild: GatewayGuild | None

Guild of the interaction.

member property #

member: InteractionMember | None

Member of the interaction.

user property #

User of the interaction.

create_response async #

create_response(content: UndefinedOr[Any] = UNDEFINED, *, flags: MessageFlag = MessageFlag.NONE, ephemeral: bool = False, attachment: UndefinedOr[Resourceish] = UNDEFINED, attachments: UndefinedOr[Sequence[Resourceish]] = UNDEFINED, component: UndefinedOr[ComponentBuilder] = UNDEFINED, components: UndefinedOr[Sequence[ComponentBuilder]] = UNDEFINED, embed: UndefinedOr[Embed] = UNDEFINED, embeds: UndefinedOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: UndefinedOr[bool] = UNDEFINED, user_mentions: UndefinedOr[SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: UndefinedOr[SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) -> None

Create a response to the interaction.

Note
  • If the interaction appears and is not deferred, it will be available for the next three seconds. After that, it will no longer be available. If your callback takes more than 3 seconds, please use InteractionContext.defer to delay the response.
  • If the interaction already has a response: default, deferred, you has to InteractionContext or you'll catch a error Interaction was already acknowledged from Discord API.

Parameters:

defer async #

defer(flags: MessageFlag = MessageFlag.NONE, *, ephemeral: bool = False) -> None

Create a deferred response to the interaction.

Note

The interaction will be available in the next 15 minutes.

Parameters:

  • flags (MessageFlag, default: MessageFlag.NONE ) –

    An optional flags for response.

  • ephemeral (bool, default: False ) –

    An optional flag to create ephemeral response. Ephemeral messages that only the author of the interaction can see. They are similar to Clyde's messages.

delete_response async #

delete_response() -> None

Delete the interaction's response.

edit_response async #

edit_response(content: UndefinedOr[Any] = UNDEFINED, *, attachment: UndefinedOr[Resourceish] = UNDEFINED, attachments: UndefinedOr[Sequence[Resourceish]] = UNDEFINED, component: UndefinedOr[ComponentBuilder] = UNDEFINED, components: UndefinedOr[Sequence[ComponentBuilder]] = UNDEFINED, embed: UndefinedOr[Embed] = UNDEFINED, embeds: UndefinedOr[Sequence[Embed]] = UNDEFINED) -> Message | None

Edit the response of the interaction.

Parameters: