flags ¶
Flag converters for Discord bot commands.
This module provides specialized flag converters for various moderation and utility commands, extending Discord.py's flag system with enhanced boolean handling and case-insensitive parsing.
Classes:
-
TuxFlagConverter–Enhanced flag converter with improved boolean flag handling.
-
BanFlags–Flags for ban commands.
-
TempBanFlags–Flags for temporary ban commands.
-
UnbanFlags–Flags for unban commands.
-
KickFlags–Flags for kick commands.
-
WarnFlags–Flags for warn commands.
-
TimeoutFlags–Flags for timeout commands.
-
UntimeoutFlags–Flags for untimeout commands.
-
JailFlags–Flags for jail commands.
-
UnjailFlags–Flags for unjail commands.
-
CasesViewFlags–Flags for viewing cases.
-
CaseModifyFlags–Flags for modifying cases.
-
SnippetBanFlags–Flags for snippet ban commands.
-
SnippetUnbanFlags–Flags for snippet unban commands.
-
PollBanFlags–Flags for poll ban commands.
-
PollUnbanFlags–Flags for poll unban commands.
-
TldrFlags–Flags for tldr commands.
Classes¶
TuxFlagConverter ¶
Bases: FlagConverter
A commands.FlagConverter but that supports Boolean flags with empty body.
Parameters:
-
commands(FlagConverter) –The base flag converter.
Returns:
-
TuxFlagConverter–The Tux flag converter.
Raises:
-
MissingFlagArgument–If a flag is missing.
-
TooManyArguments–If too many arguments are passed.
Notes
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
BanFlags ¶
Bases: TuxFlagConverter
Flags for ban commands.
Attributes:
-
reason(str) –The reason for the ban (positional argument).
-
purge(int) –Days of messages to delete (0-7).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
TempBanFlags ¶
Bases: TuxFlagConverter
Flags for temporary ban commands.
Attributes:
-
reason(str) –The reason for the ban (positional argument).
-
duration(float) –Length of the ban in seconds.
-
purge(int) –Days of messages to delete (0-7).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
UnbanFlags ¶
Bases: TuxFlagConverter
Flags for unban commands.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
KickFlags ¶
Bases: TuxFlagConverter
Flags for kick commands.
Attributes:
-
reason(str) –The reason for the kick (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
WarnFlags ¶
Bases: TuxFlagConverter
Flags for warn commands.
Attributes:
-
reason(str) –The reason for the warning (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
TimeoutFlags ¶
Bases: TuxFlagConverter
Flags for timeout commands.
Attributes:
-
reason(str) –The reason for the timeout (positional argument).
-
duration(str) –Length of the timeout (e.g. 1d, 1h).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
UntimeoutFlags ¶
Bases: TuxFlagConverter
Flags for untimeout commands.
Attributes:
-
reason(str) –The reason for the timeout removal (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
JailFlags ¶
Bases: TuxFlagConverter
Flags for jail commands.
Attributes:
-
reason(str) –The reason for the jail (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
UnjailFlags ¶
Bases: TuxFlagConverter
Flags for unjail commands.
Attributes:
-
reason(str) –The reason for the jail removal (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
CasesViewFlags ¶
Bases: TuxFlagConverter
Flags for viewing cases.
Attributes:
-
type(CaseType | None) –Type of case to view.
-
user(User | None) –User to view cases for.
-
moderator(User | None) –Moderator to view cases for.
Initialize CasesViewFlags with default values for None attributes.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
CaseModifyFlags ¶
CaseModifyFlags()
Bases: TuxFlagConverter
Flags for modifying cases.
Attributes:
Initialize CaseModifyFlags and validate that at least one field is provided.
Raises:
-
FlagError–If neither status nor reason is provided.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
SnippetBanFlags ¶
Bases: TuxFlagConverter
Flags for snippet ban commands.
Attributes:
-
reason(str) –The reason for the snippet ban (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
SnippetUnbanFlags ¶
Bases: TuxFlagConverter
Flags for snippet unban commands.
Attributes:
-
reason(str) –The reason for the snippet unban (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
PollBanFlags ¶
Bases: TuxFlagConverter
Flags for poll ban commands.
Attributes:
-
reason(str) –The reason for the poll ban (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
PollUnbanFlags ¶
Bases: TuxFlagConverter
Flags for poll unban commands.
Attributes:
-
reason(str) –The reason for the poll unban (positional argument).
-
silent(bool) –Don't send a DM to the target.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.
TldrFlags ¶
Bases: TuxFlagConverter
Flags for tldr commands.
Attributes:
-
platform(str | None) –Platform (e.g. linux, osx, common).
-
language(str | None) –Language code (e.g. en, es, fr).
-
show_short(bool) –Display shortform options over longform.
-
show_long(bool) –Display longform options over shortform.
-
show_both(bool) –Display both short and long options.
Methods:
-
parse_flags–Parse command arguments into flags with enhanced boolean handling.
Functions¶
parse_flags classmethod ¶
Parse command arguments into flags with enhanced boolean handling.
This method extends Discord.py's flag parsing to handle trailing boolean flags without explicit values (e.g., "-silent" becomes "-silent True").
Parameters:
-
argument(str) –The raw argument string to parse.
-
ignore_extra(bool, default:True) –Whether to ignore extra arguments that aren't flags. Default is True.
Returns:
Raises:
-
MissingFlagArgument–If a required flag argument is missing.
-
TooManyArguments–If too many arguments are provided when ignore_extra is False.