curious.commands.context

Class for the commands context.

Classes

Context(message, event_context) A class that represents the context for a command.
class curious.commands.context.Context(message: curious.dataclasses.message.Message, event_context: curious.core.event.EventContext)[source]

Bases: object

A class that represents the context for a command.

Parameters:
  • message (Message) – The Message this command was invoked with.
  • event_context (EventContext) – The EventContext for this context.
message = None

The message for this context.

command_name = None

The extracted command name for this context.

tokens = None

The tokens for this context.

formatted_command = None

The formatted command for this context.

plugin = None

The plugin for this context.

manager = None

The manager for this context.

event_context = None

The event context for this context.

bot = None

The Client for this context.

classmethod add_converter(converter)[source]

Adds a converter to the mapping of converters.

Parameters:
guild
Return type:Guild
Returns:The Guild for this context, or None.
channel
Return type:Channel
Returns:The Channel for this context.
author
Return type:Union[Member, User]
Returns:The Member or User for this context.
match_command(func)[source]

Attempts to match a command with this context.

Return type:bool
_lookup_converter(annotation)[source]

Looks up a converter for the specified annotation.

Return type:Callable[[Any, Context, str], Any]
await _get_converted_args(func)[source]

Gets the converted args and kwargs for this command, based on the tokens.

Return type:Tuple[tuple, dict]
_make_reraise_ctx(new_name)[source]

Makes a new EventContext for re-dispatching.

Return type:EventContext
await _safety_wrapper(coro)[source]

Runs a command in a safety wrapper.

Return type:None
await can_run(cmd)[source]

Checks if a command can be ran.

Return type:Tuple[bool, list]
Returns:If it can be ran, and a list of conditions that failed.
await invoke(command)[source]

Invokes a command. This will convert arguments, pass them in to the command, and run the command.

Parameters:command – The command function to run.
Return type:Any
await try_invoke()[source]

Attempts to invoke the command, using the specified manager.

This will scan all the commands, then invoke as appropriate.

Return type:Any