tux.cogs.moderation.command_config
¶
Dynamic moderation command configuration system.
This module provides a configuration-driven approach to moderation commands, allowing for DRY implementation and consistent behavior across all moderation actions.
Classes:
Name | Description |
---|---|
ModerationCommandConfig | Configuration for a moderation command. |
Classes¶
ModerationCommandConfig(name: str, aliases: list[str], description: str, case_type: CaseType, required_permission_level: int, supports_duration: bool, supports_purge: bool, supports_reason: bool, supports_silent: bool, dm_action: str, discord_action: Callable[[discord.Guild, discord.Member, str, dict[str, Any]], Coroutine[Any, Any, None]], requires_member: bool = True, check_timed_out: bool = False, check_already_banned: bool = False)
dataclass
¶
Configuration for a moderation command.
This dataclass defines all the behavior and parameters for a moderation command, allowing for dynamic command generation and consistent behavior.
Methods:
Name | Description |
---|---|
get_usage_string | Generate usage string for this command. |
get_help_text | Generate help text for this command. |
Functions¶
get_usage_string() -> str
¶
Generate usage string for this command.
Source code in tux/cogs/moderation/command_config.py
Python
def get_usage_string(self) -> str:
"""Generate usage string for this command."""
required_params: list[str] = ["member"] if self.requires_member else []
optional_params: list[str] = []
if self.supports_duration:
optional_params.append("duration")
if self.supports_reason:
optional_params.append("reason")
flags: list[str] = []
if self.supports_duration:
flags.append("-d")
if self.supports_purge:
flags.append("-p")
if self.supports_silent:
flags.append("-s")
return generate_mixed_usage(self.name, required_params, optional_params, flags)
get_help_text() -> str
¶
Generate help text for this command.
Source code in tux/cogs/moderation/command_config.py
Python
def get_help_text(self) -> str:
"""Generate help text for this command."""
base_text = f"{self.description}\n\n"
if self.supports_duration and self.supports_reason:
base_text += "Supports both positional and flag-based arguments:\n"
base_text += f"- Positional: `{self.name} @user 14d reason`\n"
base_text += f"- Flag-based: `{self.name} @user reason -d 14d`\n"
base_text += f"- Mixed: `{self.name} @user 14d reason -s`\n"
elif self.supports_reason:
base_text += "Supports both positional and flag-based arguments:\n"
base_text += f"- Positional: `{self.name} @user reason`\n"
base_text += f"- Flag-based: `{self.name} @user -r reason`\n"
return base_text