tanchan.components#
Commands, message components and modals implemented by Tan-chan for use with Tanjun and Yuyo.
tanchan.components.buttons #
Standard constant message components provided and used by Tanchan.
delete_row #
delete_row(ctx_or_author, /, *ctx_or_authors)
Make an action row builder with a delete button from a list of authors.
Parameters:
-
*ctx_or_authors
(Union[Snowflakeish, Context, AutocompleteContext, BaseContext[Any]]
, default:()
) –IDs of authors who should be allowed to delete the response.
Both user IDs and role IDs are supported with no IDs indicating that anybody should be able to delete the response.
Tanjun and Yuyo contexts can also be passed here to target their author.
Returns:
-
ActionRowBuilder
–Action row builder with a delete button.
on_delete_button async
#
on_delete_button(ctx)
Default implementation of a constant callback used by delete buttons.
Parameters:
-
ctx
(ComponentContext
) –The context that triggered this delete.
tanchan.components.config #
Configuration classes for Tanchan's command components.
Config #
Bases: EvalConfig
, HelpConfig
Full configuration for Tan-chan's commands and components.
Config.add_to_client should be used to set this config.
Examples:
client = tanjun.Client.from_gateway_bot(bot)
config = yuyo.components.config.Config(
eval_guild_ids=None,
enable_slash_command=True,
)
config.add_to_client(client)
enable_message_command class-attribute
instance-attribute
#
enable_message_command = True
Whether the help message command should be enabled.
enable_slash_command class-attribute
instance-attribute
#
enable_slash_command = False
Whether the help slash command should be enabled.
eval_guild_ids class-attribute
instance-attribute
#
eval_guild_ids = field(default=())
ID of the guilds the eval slash command should be declared in.
If None then the slash command will be declared in every guild (globally) and an empty collection ensures it isn't declared.
include_message_commands class-attribute
instance-attribute
#
include_message_commands = True
include_slash_commands class-attribute
instance-attribute
#
include_slash_commands = False
EvalConfig #
Configuration for the eval commands.
EvalConfig.add_to_client should be used to set this config.
Examples:
client = tanjun.Client.from_gateway_bot(bot)
(
yuyo.components.config.EvalConfig(eval_guild_ids=None)
.add_to_client(client)
)
HelpConfig #
Configuration for the help commands.
HelpConfig.add_to_client should be used to set this config.
Examples:
client = tanjun.Client.from_gateway_bot(bot)
(
yuyo.components.config.HelpConfig(enable_slash_command=True)
.add_to_client(client)
)
enable_message_command class-attribute
instance-attribute
#
enable_message_command = True
Whether the help message command should be enabled.
enable_slash_command class-attribute
instance-attribute
#
enable_slash_command = False
Whether the help slash command should be enabled.
include_message_commands class-attribute
instance-attribute
#
include_message_commands = True
include_slash_commands class-attribute
instance-attribute
#
include_slash_commands = False
tanchan.components.eval #
tanchan.components.help #
A components powered help command.
hide_from_help #
hide_from_help(cmd=None, /, *, follow_wrapped=False)
Hide a global command from the help command.
Parameters:
-
follow_wrapped
(bool
, default:False
) –Whether this should also apply the help information to the other command objects this wraps in a decorator call chain.
Examples:
@hide_from_command
@tanjun.as_message_command("name")
async def command(ctx: tanjun.abc.Context) -> None:
'''Meow command.'''
with_help #
with_help(description=None, /, *, category=None, follow_wrapped=False)
Override the help string for the command.
Parameters:
-
description
(Union[str, Mapping[str, str], None]
, default:None
) –Description to set for the command.
This supports Tanjun's localisation.
-
category
(Optional[str]
, default:None
) –Name of the category this command should be in. Defaults to the component's name.
-
follow_wrapped
(bool
, default:False
) –Whether this should also apply the help information to the other command objects this wraps in a decorator call chain.
Examples:
@hide_from_command("Alternative description.")
@tanjun.as_message_command("name")
async def command(ctx: tanjun.abc.Context) -> None:
...