Skip to content

tanjun.context#

Standard implementations of Tanjun's context classes.

tanjun.context.autocomplete #

Autocomplete context implementation.

AutocompleteContext #

Bases: alluka.BasicContext, tanjun.AutocompleteContext

Standard implementation of an autocomplete context.

__init__(client, interaction, *, future=None) #

Initialise an autocomplete context.

PARAMETER DESCRIPTION
client

The Tanjun client this context is bound to.

TYPE: tanjun.Client

interaction

The autocomplete interaction this context is for.

TYPE: hikari.AutocompleteInteraction

future

A future used to set the initial response if this is being called through the REST webhook flow.

TYPE: typing.Optional[asyncio.Future[hikari.api.InteractionAutocompleteBuilder]] DEFAULT: None

tanjun.context.menu #

Menu context implementation.

MenuContext #

Bases: slash.AppCommandContext, tanjun.MenuContext

Standard menu command execution context.

__init__(client, interaction, register_task, *, default_to_ephemeral=False, future=None, on_not_found=None) #

Initialise a menu command context.

PARAMETER DESCRIPTION
client

The Tanjun client this context is bound to.

TYPE: tanjun.Client

interaction

The command interaction this context is for.

TYPE: hikari.CommandInteraction

register_task

Callback used to register long-running tasks spawned by this context.

TYPE: collections.Callable[[asyncio.Task[typing.Any]], None]

future

A future used to set the initial response if this is being called through the REST webhook flow.

TYPE: typing.Optional[asyncio.Future[_ResponseTypeT]] DEFAULT: None

default_to_ephemeral

Whether to default to ephemeral responses.

TYPE: bool DEFAULT: False

on_not_found

Callback used to indicate no matching command was found.

TYPE: typing.Optional[collections.Callable[[tanjun.MenuContext], collections.Awaitable[None]]] DEFAULT: None

tanjun.context.message #

Message command implementation.

MessageContext #

Bases: base.BaseContext, tanjun.MessageContext

Standard implementation of a command context as used within Tanjun.

__init__(client, content, message, register_task, *, triggering_name='', triggering_prefix='') #

Initialise a message command context.

PARAMETER DESCRIPTION
client

The client to use for sending messages.

TYPE: tanjun.Client

content

The content of the message (minus any matched prefix and name).

TYPE: str

message

The message that triggered the command.

TYPE: hikari.Message

register_task

Callback used to register long-running tasks spawned by this context.

TYPE: collections.Callable[[asyncio.Task[typing.Any]], None]

triggering_name

The name of the command that triggered this context.

TYPE: str DEFAULT: ''

triggering_prefix

The prefix that triggered this context.

TYPE: str DEFAULT: ''

set_triggering_prefix(triggering_prefix) #

Set the triggering prefix for this context.

PARAMETER DESCRIPTION
triggering_prefix

The triggering prefix to set.

TYPE: str

RETURNS DESCRIPTION
Self

This context to allow for chaining.

tanjun.context.slash #

Slash command implementation.

AppCommandContext #

Bases: base.BaseContext, tanjun.AppCommandContext

Base class for interaction-based command contexts.

cancel_defer() #

Cancel the auto-deferral if its active.

start_defer_timer(count_down) #

Start the auto-deferral timer.

PARAMETER DESCRIPTION
count_down

The number of seconds to wait before automatically deferring the interaction.

TYPE: typing.Union[int, float]

RETURNS DESCRIPTION
Self

This context to allow for chaining.

SlashContext #

Bases: AppCommandContext, tanjun.SlashContext

Standard implementation of tanjun.abc.SlashContext.

__init__(client, interaction, register_task, *, default_to_ephemeral=False, future=None, on_not_found=None) #

Initialise a slash command context.

PARAMETER DESCRIPTION
client

The Tanjun client this context is bound to.

TYPE: tanjun.Client

interaction

The command interaction this context is for.

TYPE: hikari.CommandInteraction

register_task

Callback used to register long-running tasks spawned by this context.

TYPE: collections.Callable[[asyncio.Task[typing.Any]], None]

default_to_ephemeral

Whether to default to ephemeral responses.

TYPE: bool DEFAULT: False

future

A future used to set the initial response if this is being called through the REST webhook flow.

TYPE: typing.Optional[asyncio.Future[_ResponseTypeT]] DEFAULT: None

on_not_found

Callback used to indicate no matching command was found.

TYPE: typing.Optional[collections.Callable[[tanjun.SlashContext], collections.Awaitable[None]]] DEFAULT: None

SlashOption #

Bases: tanjun.SlashOption

Standard implementation of the SlashOption interface.

__init__(resolved, option) #

Initialise a slash option.

PARAMETER DESCRIPTION
resolved

The resolved option data if applicable.

TYPE: typing.Optional[hikari.ResolvedOptionData]

option

The raw interaction option.

TYPE: hikari.CommandInteractionOption