Context
AutocompleteContext
dataclass
#
AutocompleteContext(
interaction: PartialInteraction,
app: GatewayTraits | RESTTraits,
client: Client,
application_id: Snowflake,
type: int,
token: str,
id: Snowflake,
version: int,
channel_id: Snowflake,
guild_id: Snowflake | None,
registered_guild_id: Snowflake | None,
user: User,
member: Member | None,
entitlements: Sequence[hikari.Entitlement],
locale: Locale,
command: str,
command_type: hikari.CommandType,
group: str | None,
sub_group: str | None,
options: dict[str, Any],
_has_created_response: bool,
_has_deferred_response: bool,
_rest_interaction_future: Future[
InteractionResponseBuilder
]
| None,
)
Bases: InteractionContext
Represents the context for autocomplete interactions
application_id
instance-attribute
#
application_id: Snowflake
The ID for the client that this interaction belongs to.
channel_id
instance-attribute
#
channel_id: Snowflake
The channel ID of the channel that the interaction was used in.
entitlements
instance-attribute
#
entitlements: Sequence[hikari.Entitlement]
For monetized apps, any entitlements involving this user. Represents access to SKUs.
guild_id
instance-attribute
#
guild_id: Snowflake | None
The guild ID of the guild that this interaction was used in.
member
instance-attribute
#
member: Member | None
The member object for the user that triggered this interaction, if used in a guild.
registered_guild_id
instance-attribute
#
registered_guild_id: Snowflake | None
The guild ID of the guild that this command is registered to.
Context
dataclass
#
Context(
interaction: PartialInteraction,
app: GatewayTraits | RESTTraits,
client: Client,
application_id: Snowflake,
type: int,
token: str,
id: Snowflake,
version: int,
channel_id: Snowflake,
guild_id: Snowflake | None,
registered_guild_id: Snowflake | None,
user: User,
member: Member | None,
entitlements: Sequence[hikari.Entitlement],
locale: Locale,
command: str,
command_type: hikari.CommandType,
group: str | None,
sub_group: str | None,
options: dict[str, Any],
_has_created_response: bool,
_has_deferred_response: bool,
_rest_interaction_future: Future[
InteractionResponseBuilder
]
| None,
)
Bases: InteractionContext
Represents the context for command interactions
application_id
instance-attribute
#
application_id: Snowflake
The ID for the client that this interaction belongs to.
channel
property
#
channel: PermissibleGuildChannel | GuildThreadChannel | None
Get this context's guild channel or thread from the cache.
📝 This will always be
None
for interactions triggered in a DM channel.
channel_id
instance-attribute
#
channel_id: Snowflake
The channel ID of the channel that the interaction was used in.
entitlements
instance-attribute
#
entitlements: Sequence[hikari.Entitlement]
For monetized apps, any entitlements involving this user. Represents access to SKUs.
guild_id
instance-attribute
#
guild_id: Snowflake | None
The guild ID of the guild that this interaction was used in.
member
instance-attribute
#
member: Member | None
The member object for the user that triggered this interaction, if used in a guild.
registered_guild_id
instance-attribute
#
registered_guild_id: Snowflake | None
The guild ID of the guild that this command is registered to.
version
instance-attribute
#
version: int
Version of the interaction system this interaction is under.
defer
async
#
defer(ephemeral: bool = False) -> None
Defer this interaction response, allowing you to respond within the next 15 minutes.
edit
async
#
edit(
content: UndefinedNoneOr[Any] = UNDEFINED,
*,
attachment: UndefinedNoneOr[
Resourceish | Attachment
] = UNDEFINED,
attachments: UndefinedNoneOr[
Sequence[Resourceish | Attachment]
] = UNDEFINED,
component: UndefinedNoneOr[
ComponentBuilder
] = UNDEFINED,
components: UndefinedNoneOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
embed: UndefinedNoneOr[Embed] = UNDEFINED,
embeds: UndefinedNoneOr[Sequence[Embed]] = UNDEFINED,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = UNDEFINED
) -> Message
Edit the previous response to this interaction.
Example#
import asyncio
@client.include
@crescent.command
async def command(ctx: crescent.Context):
await ctx.respond("hello there")
await asyncio.sleep(3)
await ctx.edit("general kenobi")
📝 Message flags are ignored in followup responses.
PARAMETER | DESCRIPTION |
---|---|
content |
The content to send.
TYPE:
|
attachment |
A single attachment to send.
TYPE:
|
attachments |
A list of attachments to send.
TYPE:
|
component |
A single component to send.
TYPE:
|
components |
A list of components to send.
TYPE:
|
embed |
A single embed to send.
TYPE:
|
embeds |
A list of embeds to send.
TYPE:
|
mentions_everyone |
Allow
TYPE:
|
user_mentions |
If
TYPE:
|
role_mentions |
If
TYPE:
|
respond
async
#
respond(
content: UndefinedOr[Any] = UNDEFINED,
*,
ephemeral: bool = False,
flags: int | MessageFlag | UndefinedType = UNDEFINED,
tts: UndefinedOr[bool] = 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,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = UNDEFINED,
ensure_message: bool = False
) -> Message | None
Respond to an interaction. This function can be used multiple times for one interaction,
Example#
@client.include
@crescent.command
async def command(ctx: crescent.Context):
# Initial response
await ctx.respond("hello")
# After the first response, a followup response will be sent.
await ctx.respond("word")
📝 Message flags are ignored in followup responses.
PARAMETER | DESCRIPTION |
---|---|
content |
The content to send.
TYPE:
|
ephemeral |
Send this message as ephemeral if set to true. Ephemeral messages can be dismissed by the user, similar to Clyde messages. This kwarg only affects the initial response to an interaction.
TYPE:
|
flags |
Message flags to send with the message. You do not need to use
this, and exists for compatibility in the future. Instead set
the
TYPE:
|
tts |
If true, send a text to speech message.
TYPE:
|
attachment |
A single attachment to send.
TYPE:
|
attachments |
A list of attachments to send.
TYPE:
|
component |
A single component to send.
TYPE:
|
components |
A list of components to send.
TYPE:
|
embed |
A single embed to send.
TYPE:
|
embeds |
A list of embeds to send.
TYPE:
|
mentions_everyone |
Allow
TYPE:
|
user_mentions |
If
TYPE:
|
role_mentions |
If
TYPE:
|
ensure_message |
A message is not returned the first time you use
TYPE:
|
respond_with_builder
async
#
Respond to an interaction with a builder.
PARAMETER | DESCRIPTION |
---|---|
builder |
The builder to respond with.
TYPE:
|
ensure_message |
If an InteractionMessageBuilder is passed, this will fetch the message and return it. Otherwise does nothing.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InteractionAlreadyAcknowledgedError
|
Raised when calling this method after responding to an interaction. |
RETURNS | DESCRIPTION |
---|---|
Message | None
|
The message if |
respond_with_modal
async
#
respond_with_modal(
title: str,
custom_id: str,
components: Sequence[ComponentBuilder],
) -> None
Respond to an interaction with a modal.
PARAMETER | DESCRIPTION |
---|---|
title |
The title of the modal.
TYPE:
|
custom_id |
The custom id of the modal.
TYPE:
|
components |
The components to add to the modal.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InteractionAlreadyAcknowledgedError
|
Raised when calling this method after responding to an interaction. |
InteractionContext
dataclass
#
InteractionContext(
interaction: PartialInteraction,
app: GatewayTraits | RESTTraits,
client: Client,
application_id: Snowflake,
type: int,
token: str,
id: Snowflake,
version: int,
channel_id: Snowflake,
guild_id: Snowflake | None,
registered_guild_id: Snowflake | None,
user: User,
member: Member | None,
entitlements: Sequence[hikari.Entitlement],
locale: Locale,
command: str,
command_type: hikari.CommandType,
group: str | None,
sub_group: str | None,
options: dict[str, Any],
_has_created_response: bool,
_has_deferred_response: bool,
_rest_interaction_future: Future[
InteractionResponseBuilder
]
| None,
)
Represents the context for interactions
application_id
instance-attribute
#
application_id: Snowflake
The ID for the client that this interaction belongs to.
channel_id
instance-attribute
#
channel_id: Snowflake
The channel ID of the channel that the interaction was used in.
entitlements
instance-attribute
#
entitlements: Sequence[hikari.Entitlement]
For monetized apps, any entitlements involving this user. Represents access to SKUs.
guild_id
instance-attribute
#
guild_id: Snowflake | None
The guild ID of the guild that this interaction was used in.
member
instance-attribute
#
member: Member | None
The member object for the user that triggered this interaction, if used in a guild.
registered_guild_id
instance-attribute
#
registered_guild_id: Snowflake | None
The guild ID of the guild that this command is registered to.