Skip to content

dev

Development and administrative commands for the Tux bot.

This module provides various administrative commands for bot management, including command synchronization, emoji management, and system information.

Classes:

  • Dev

    Discord cog for development and administrative commands.

Functions:

  • setup

    Set up the Dev cog.

Classes

Dev

Python
Dev(bot: Tux)

Bases: BaseCog

Discord cog for development and administrative commands.

This cog provides various administrative commands for bot management and development tasks, including command synchronization and emoji management.

Initialize the Dev cog.

Parameters:

  • bot (Tux) –

    The bot instance to attach this cog to.

Methods:

  • dev

    Dev related commands.

  • sync_tree

    Sync the app command tree.

  • clear_tree

    Clear the app command tree.

  • emoji

    Emoji management commands.

  • sync_emojis

    Synchronize emojis from the local assets directory to the application.

  • get_config

    Get a configuration value from CONFIG with support for nested keys.

  • resync_emoji

    Resync a specific emoji from the local assets directory.

  • __repr__

    Return a string representation of the cog instance.

  • unload_if_missing_config

    Check if required configuration is missing and log warning.

  • delete_all_emojis

    Delete all application emojis that match names from the emoji assets directory.

  • list_emojis

    List all emojis currently in the emoji manager's cache.

  • load_cog

    Load a cog into the bot.

  • unload_cog

    Unload a cog from the bot.

  • reload_cog

    Reload a cog in the bot.

  • stop

    Stop the bot. If Tux is running with Docker Compose, this will restart the container.

Attributes:

Attributes

db property

Get the database coordinator for accessing database controllers.

Returns:

  • DatabaseCoordinator

    Coordinator providing access to all database controllers.

Examples:

Python Console Session
>>> await self.db.guild_config.get_guild_config(guild_id)
>>> await self.db.cases.create_case(...)
Notes

This property provides convenient access to database operations without needing to access self.bot.db directly.

Functions

_resolve_cog_path
Python
_resolve_cog_path(cog_name: str) -> str

Resolve a short cog name to a full module path.

This method attempts to resolve short names like "ping" to full paths like "tux.modules.utility.ping" or "tux.plugins.atl.mock" by recursively searching through both the modules and plugins directories (including all subdirectories). It also handles partial paths like "modules.utility.ping" by prepending "tux." as needed.

Examples:

  • "ping" → "tux.modules.utility.ping"
  • "mock" → "tux.plugins.atl.mock"
  • "modules.utility.ping" → "tux.modules.utility.ping"
  • "plugins.atl.mock" → "tux.plugins.atl.mock"
  • "tux.modules.utility.ping" → "tux.modules.utility.ping" (unchanged)
  • "something" → "tux.plugins.xyz.something" (if in plugins/xyz/)

Parameters:

  • cog_name (str) –

    The cog name to resolve (can be short or full path).

Returns:

  • str

    The resolved full module path, or the original name if already a full path or if resolution fails.

_setup_command_usage
Python
_setup_command_usage() -> None

Generate usage strings for all commands in this cog that lack explicit usage.

The generated usage follows the pattern: <qualified_name> <param tokens>

Where: - Required parameters are denoted as <name: Type> - Optional parameters are denoted as [name: Type] - The prefix is intentionally omitted (provided by ctx.prefix)

Examples:

ban <member: Member> [reason: str] config set <key: str> <value: str>

Notes

Respects explicit usage strings if already set on a command. Errors during generation are logged but don't prevent cog loading.

dev async
Python
dev(ctx: Context[Tux]) -> None

Dev related commands.

Parameters:

  • ctx (Context[Tux]) –

    The context object for the command.

sync_tree async
Python
sync_tree(ctx: Context[Tux], guild: Guild) -> None

Sync the app command tree.

Parameters:

  • ctx (Context) –

    The context in which the command is being invoked.

  • guild (Guild) –

    The guild to sync application commands to.

_generate_usage
Python
_generate_usage(command: Command[Any, ..., Any]) -> str

Generate a usage string with support for flags and positional parameters.

This method inspects the command's callback signature to detect: - FlagConverter parameters (e.g., --flag value) - Positional parameters (e.g., <required> or [optional])

Parameters:

  • command (Command) –

    The command to generate usage for.

Returns:

  • str

    Generated usage string, or qualified command name as fallback.

Notes

Delegates to shared usage generator for consistency across all cogs. Falls back gracefully to command name if generation fails.

clear_tree async
Python
clear_tree(ctx: Context[Tux]) -> None

Clear the app command tree.

Parameters:

  • ctx (Context) –

    The context in which the command is being invoked.

emoji async
Python
emoji(ctx: Context[Tux]) -> None

Emoji management commands.

Parameters:

  • ctx (Context[Tux]) –

    The context object for the command.

sync_emojis async
Python
sync_emojis(ctx: Context[Tux]) -> None

Synchronize emojis from the local assets directory to the application.

This command: 1. Scans the emoji assets directory 2. Uploads any missing emojis to the application 3. Reports which emojis were created and which were skipped

Parameters:

  • ctx (Context[Tux]) –

    The context object for the command.

get_config
Python
get_config(key: str, default: Any = None) -> Any

Get a configuration value from CONFIG with support for nested keys.

Parameters:

  • key (str) –

    The configuration key to retrieve. Supports dot notation for nested values (e.g., "BOT_INFO.BOT_NAME").

  • default (Any, default: None ) –

    Default value to return if key is not found, by default None.

Returns:

  • Any

    The configuration value or default if not found.

Examples:

Python Console Session
>>> self.get_config("BOT_INFO.BOT_NAME")
'Tux'
>>> self.get_config("MISSING_KEY", "fallback")
'fallback'
Notes

Errors during retrieval are logged but don't raise exceptions. Returns the default value on any error.

resync_emoji async
Python
resync_emoji(ctx: Context[Tux], emoji_name: str) -> None

Resync a specific emoji from the local assets directory.

This command: 1. Deletes the existing emoji with the given name (if it exists) 2. Creates a new emoji using the local file with the same name 3. Reports the results

Parameters:

  • ctx (Context[Tux]) –

    The context object for the command.

  • emoji_name (str) –

    The name of the emoji to resync.

__repr__
Python
__repr__() -> str

Return a string representation of the cog instance.

Returns:

  • str

    String representation in format <CogName bot=BotUser>.

unload_if_missing_config
Python
unload_if_missing_config(condition: bool, config_name: str) -> bool

Check if required configuration is missing and log warning.

This allows cogs to detect missing configuration at load time and return early from init to prevent partial initialization.

Parameters:

  • condition (bool) –

    True if config is missing (should unload), False otherwise.

  • config_name (str) –

    Name of the missing configuration for logging purposes.

Returns:

  • bool

    True if config is missing (caller should return early), False if config is present.

Examples:

Python Console Session
>>> def __init__(self, bot: Tux):
...     super().__init__(bot)
...     if self.unload_if_missing_config(not CONFIG.GITHUB_TOKEN, "GITHUB_TOKEN"):
...         return  # Exit early, cog will be partially loaded but won't register commands
...     self.github_client = GitHubClient()
Notes

When this returns True, the cog's init should return early to avoid initializing services that depend on the missing config. The cog will be loaded but commands won't be registered properly, preventing runtime errors.

For complete cog unloading, the bot owner should remove the cog from the modules directory or use the reload system to unload it programmatically.

delete_all_emojis async
Python
delete_all_emojis(ctx: Context[Tux]) -> None

Delete all application emojis that match names from the emoji assets directory.

This command: 1. Scans the emoji assets directory for valid emoji names 2. Deletes all application emojis with matching names 3. Reports which emojis were deleted and which failed

Parameters:

  • ctx (Context[Tux]) –

    The context object for the command.

_unload_self async
Python
_unload_self(extension_name: str) -> None

Perform the actual cog unload operation.

Parameters:

  • extension_name (str) –

    Full extension name to unload.

Notes

This is called as a background task by unload_if_missing_config(). Errors during unload are logged but don't raise exceptions.

list_emojis async
Python
list_emojis(ctx: Context[Tux]) -> None

List all emojis currently in the emoji manager's cache.

This command: 1. Shows all emojis in the bot's emoji cache 2. Displays emoji count and names

Parameters:

  • ctx (Context[Tux]) –

    The context object for the command.

load_cog async
Python
load_cog(ctx: Context[Tux], *, cog: str) -> None

Load a cog into the bot.

This command supports automatic path resolution. You can use short names like "ping" which will be resolved to "tux.modules.utility.ping", or provide the full module path directly.

Parameters:

  • ctx (Context) –

    The context in which the command is being invoked.

  • cog (str) –

    The name of the cog to load (short name or full module path).

unload_cog async
Python
unload_cog(ctx: Context[Tux], *, cog: str) -> None

Unload a cog from the bot.

This command supports automatic path resolution. You can use short names like "ping" which will be resolved to "tux.modules.utility.ping", or provide the full module path directly.

Parameters:

  • ctx (Context) –

    The context in which the command is being invoked.

  • cog (str) –

    The name of the cog to unload (short name or full module path).

reload_cog async
Python
reload_cog(ctx: Context[Tux], *, cog: str) -> None

Reload a cog in the bot.

This command supports automatic path resolution. You can use short names like "ping" which will be resolved to "tux.modules.utility.ping", or provide the full module path directly.

Parameters:

  • ctx (Context) –

    The context in which the command is being invoked.

  • cog (str) –

    The name of the cog to reload (short name or full module path).

stop async
Python
stop(ctx: Context[Tux]) -> None

Stop the bot. If Tux is running with Docker Compose, this will restart the container.

Parameters:

  • ctx (Context) –

    The context in which the command is being invoked.

Functions

setup async

Python
setup(bot: Tux) -> None

Set up the Dev cog.

Parameters:

  • bot (Tux) –

    The bot instance to add the cog to.