tanjun.context#
Standard implementations of Tanjun's context classes.
tanjun.context.autocomplete #
Autocomplete context implementation.
AutocompleteContext #
Bases: BasicContext, AutocompleteContext
Standard implementation of an autocomplete context.
__init__ #
__init__(client, interaction, *, future=None)
Initialise an autocomplete context.
Parameters:
-
client(Client) –The Tanjun client this context is bound to.
-
interaction(AutocompleteInteraction) –The autocomplete interaction this context is for.
-
future(Future[InteractionAutocompleteBuilder] | None, default:None) –A future used to set the initial response if this is being called through the REST webhook flow.
tanjun.context.menu #
Menu context implementation.
MenuContext #
Bases: AppCommandContext, MenuContext
Standard menu command execution context.
__init__ #
__init__(client, interaction, register_task, *, default_to_ephemeral=False, future=None, on_not_found=None)
Initialise a menu command context.
Parameters:
-
client(Client) –The Tanjun client this context is bound to.
-
interaction(CommandInteraction) –The command interaction this context is for.
-
register_task(Callable[[Task[Any]], None]) –Callback used to register long-running tasks spawned by this context.
-
future(Future[_ResponseTypeT] | None, default:None) –A future used to set the initial response if this is being called through the REST webhook flow.
-
default_to_ephemeral(bool, default:False) –Whether to default to ephemeral responses.
-
on_not_found(Callable[[MenuContext], Awaitable[None]] | None, default:None) –Callback used to indicate no matching command was found.
tanjun.context.message #
Message command implementation.
MessageContext #
Bases: BaseContext, MessageContext
Standard implementation of a command context as used within Tanjun.
__init__ #
__init__(client, content, message, register_task, *, triggering_name='', triggering_prefix='')
Initialise a message command context.
Parameters:
-
client(Client) –The client to use for sending messages.
-
content(str) –The content of the message (minus any matched prefix and name).
-
message(Message) –The message that triggered the command.
-
register_task(Callable[[Task[Any]], None]) –Callback used to register long-running tasks spawned by this context.
-
triggering_name(str, default:'') –The name of the command that triggered this context.
-
triggering_prefix(str, default:'') –The prefix that triggered this context.
tanjun.context.slash #
Slash command implementation.
AppCommandContext #
Bases: BaseContext, AppCommandContext
Base class for interaction-based command contexts.
command abstractmethod property #
command
Object of the command this context is bound to.
Note
This will only be None before this has been bound to a specific command but never during command execution.
triggering_name abstractmethod property #
triggering_name
Command name this execution was triggered with.
finalise #
finalise()
Finalise the context, dis-allowing any further modifications.
Returns:
-
Self–The context itself to enable chained calls.
mark_not_found abstractmethod async #
mark_not_found()
Mark this context as not found.
Dependent on how the client is configured this may lead to a not found response message being sent.
SlashContext #
Bases: AppCommandContext, SlashContext
Standard implementation of tanjun.abc.SlashContext.
__init__ #
__init__(client, interaction, register_task, *, default_to_ephemeral=False, future=None, on_not_found=None)
Initialise a slash command context.
Parameters:
-
client(Client) –The Tanjun client this context is bound to.
-
interaction(CommandInteraction) –The command interaction this context is for.
-
register_task(Callable[[Task[Any]], None]) –Callback used to register long-running tasks spawned by this context.
-
default_to_ephemeral(bool, default:False) –Whether to default to ephemeral responses.
-
future(Future[_ResponseTypeT] | None, default:None) –A future used to set the initial response if this is being called through the REST webhook flow.
-
on_not_found(Callable[[SlashContext], Awaitable[None]] | None, default:None) –Callback used to indicate no matching command was found.
SlashOption #
Bases: SlashOption
Standard implementation of the SlashOption interface.
__init__ #
__init__(resolved, option)
Initialise a slash option.
Parameters:
-
resolved(ResolvedOptionData | None) –The resolved option data if applicable.
-
option(CommandInteractionOption) –The raw interaction option.