curious.commands.utils¶
Misc utilities used in commands related things.
Functions
get_description (func) |
Gets the description of a function. | ||
get_full_name (func) |
Gets the full name of a command, taking into account it’s parents. | ||
get_usage (func[, invoked_as]) |
|
||
prefix_check_factory (prefix) |
The default message function factory. | ||
split_message_content (content[, delim]) |
Splits a message into individual parts by delim, returning a list of strings. | ||
stringify (ann) |
Stringifies an annotation. |
-
await
curious.commands.utils.
_convert
(ctx, tokens, signature)[source]¶ Converts tokens passed from discord, using a signature.
-
curious.commands.utils.
get_description
(func)[source]¶ Gets the description of a function.
Parameters: func – The function. Return type: str
Returns: The description extracted from the docstring, or None.
-
curious.commands.utils.
get_full_name
(func)[source]¶ Gets the full name of a command, taking into account it’s parents.
Return type: str
-
curious.commands.utils.
get_usage
(func, invoked_as=None)[source]¶ Return type: str
Returns: The usage text for this command.
-
curious.commands.utils.
prefix_check_factory
(prefix)[source]¶ The default message function factory.
This provides a callable that will fire a command if the message begins with the specified prefix or list of prefixes.
If
command_prefix
is provided to theClient
, then it will automatically call this function to get a message check function to use.# verbose form message_check = prefix_check_factory(["!", "?"]) cl = Client(message_check=message_check) # implicit form cl = Client(command_prefix=["!", "?"])
The
prefix
is set on the returned function that can be used to retrieve the prefixes defined to create the function at any time.Parameters: prefix ( Union
[str
,Iterable
[str
],Callable
[[Client
,Message
],str
]]) – Astr
ortyping.Iterable[str]
that represents the prefix(es) to use.Returns: A callable that can be used for the message_check
function on the client.
-
curious.commands.utils.
split_message_content
(content, delim=' ')[source]¶ Splits a message into individual parts by delim, returning a list of strings. This method preserves quotes.
content = '!send "Fuyukai desu" "Hello, world!"' split = split_message_content(content, delim=" ")
Parameters: Return type: Returns: A list of items split