Annotations
argument
¶
class
CMD_BODY (NoArgumentConverter)
¶
This argument is for the body of the message.
IE:
if @bot hello how are you?
is sent this argument will be hello how are you?
Source code in naff/models/naff/annotations/argument.py
class CMD_BODY(NoArgumentConverter[str]):
"""
This argument is for the body of the message.
IE:
if `@bot hello how are you?` is sent this argument will be `hello how are you?`
"""
async def convert(self, context: Context, _) -> str:
"""Returns the body of the message."""
if not isinstance(context, PrefixedContext):
raise BadArgument("CMD_BODY can only be used with prefixed commands.")
return context.content_parameters
async
method
convert(self, context, _)
¶
Returns the body of the message.
Source code in naff/models/naff/annotations/argument.py
async def convert(self, context: Context, _) -> str:
"""Returns the body of the message."""
if not isinstance(context, PrefixedContext):
raise BadArgument("CMD_BODY can only be used with prefixed commands.")
return context.content_parameters
class
CMD_AUTHOR (NoArgumentConverter)
¶
This argument is the author of the context.
Source code in naff/models/naff/annotations/argument.py
class CMD_AUTHOR(NoArgumentConverter):
"""This argument is the author of the context."""
async def convert(self, context: Context, _) -> "Member | User":
"""Returns the author of the context."""
return context.author
async
method
convert(self, context, _)
¶
Returns the author of the context.
Source code in naff/models/naff/annotations/argument.py
async def convert(self, context: Context, _) -> "Member | User":
"""Returns the author of the context."""
return context.author
class
CMD_CHANNEL (NoArgumentConverter)
¶
This argument is the channel the command was sent in.
Source code in naff/models/naff/annotations/argument.py
class CMD_CHANNEL(NoArgumentConverter):
"""This argument is the channel the command was sent in."""
async def convert(self, context: Context, _) -> "TYPE_MESSAGEABLE_CHANNEL":
"""Returns the channel of the context."""
return context.channel
async
method
convert(self, context, _)
¶
Returns the channel of the context.
Source code in naff/models/naff/annotations/argument.py
async def convert(self, context: Context, _) -> "TYPE_MESSAGEABLE_CHANNEL":
"""Returns the channel of the context."""
return context.channel
class
CMD_ARGS (NoArgumentConverter)
¶
This argument is all of the arguments sent with this context.
Source code in naff/models/naff/annotations/argument.py
class CMD_ARGS(NoArgumentConverter[list[str]]):
"""This argument is all of the arguments sent with this context."""
@staticmethod
async def convert(context: Context, _) -> list[str]:
"""Returns the arguments for this context."""
return context.args
async
staticmethod
method
convert(context, _)
¶
Returns the arguments for this context.
Source code in naff/models/naff/annotations/argument.py
@staticmethod
async def convert(context: Context, _) -> list[str]:
"""Returns the arguments for this context."""
return context.args
slash
¶
function
slash_str_option(description, required, autocomplete, choices, min_length, max_length)
¶
Annotates an argument as a string type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
choices |
List[Union[SlashCommandChoice, dict]] |
The choices allowed by this command |
None |
min_length |
Optional[int] |
The minimum length of text a user can input. |
None |
max_length |
Optional[int] |
The maximum length of text a user can input. |
None |
Source code in naff/models/naff/annotations/slash.py
def slash_str_option(
description: str,
required: bool = False,
autocomplete: bool = False,
choices: List[Union["SlashCommandChoice", dict]] = None,
min_length: Optional[int] = None,
max_length: Optional[int] = None,
) -> Type[str]:
"""
Annotates an argument as a string type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
choices: The choices allowed by this command
min_length: The minimum length of text a user can input.
max_length: The maximum length of text a user can input.
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
choices=choices or [],
max_length=max_length,
min_length=min_length,
type=models.OptionTypes.STRING,
)
return option # type: ignore
function
slash_float_option(description, required, autocomplete, choices, min_value, max_value)
¶
Annotates an argument as a float type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
choices |
List[Union[SlashCommandChoice, dict]] |
The choices allowed by this command |
None |
min_value |
Optional[float] |
The minimum number allowed |
None |
max_value |
Optional[float] |
The maximum number allowed |
None |
Source code in naff/models/naff/annotations/slash.py
def slash_float_option(
description: str,
required: bool = False,
autocomplete: bool = False,
choices: List[Union["SlashCommandChoice", dict]] = None,
min_value: Optional[float] = None,
max_value: Optional[float] = None,
) -> Type[float]:
"""
Annotates an argument as a float type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
choices: The choices allowed by this command
min_value: The minimum number allowed
max_value: The maximum number allowed
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
choices=choices or [],
max_value=max_value,
min_value=min_value,
type=models.OptionTypes.NUMBER,
)
return option # type: ignore
function
slash_int_option(description, required, autocomplete, choices, min_value, max_value)
¶
Annotates an argument as a integer type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
choices |
List[Union[SlashCommandChoice, dict]] |
The choices allowed by this command |
None |
min_value |
Optional[float] |
The minimum number allowed |
None |
max_value |
Optional[float] |
The maximum number allowed |
None |
Source code in naff/models/naff/annotations/slash.py
def slash_int_option(
description: str,
required: bool = False,
autocomplete: bool = False,
choices: List[Union["SlashCommandChoice", dict]] = None,
min_value: Optional[float] = None,
max_value: Optional[float] = None,
) -> Type[int]:
"""
Annotates an argument as a integer type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
choices: The choices allowed by this command
min_value: The minimum number allowed
max_value: The maximum number allowed
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
choices=choices or [],
max_value=max_value,
min_value=min_value,
type=models.OptionTypes.INTEGER,
)
return option # type: ignore
function
slash_bool_option(description, required)
¶
Annotates an argument as a boolean type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
Source code in naff/models/naff/annotations/slash.py
def slash_bool_option(
description: str,
required: bool = False,
) -> Type[bool]:
"""
Annotates an argument as a boolean type slash command option.
Args:
description: The description of your option
required: Is this option required?
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
type=models.OptionTypes.BOOLEAN,
)
return option # type: ignore
function
slash_user_option(description, required, autocomplete)
¶
Annotates an argument as a user type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
Source code in naff/models/naff/annotations/slash.py
def slash_user_option(
description: str,
required: bool = False,
autocomplete: bool = False,
) -> Type[Union["User", "Member"]]:
"""
Annotates an argument as a user type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
type=models.OptionTypes.USER,
)
return option # type: ignore
function
slash_channel_option(description, required, autocomplete, choices, channel_types)
¶
Annotates an argument as a channel type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
choices |
List[Union[SlashCommandChoice, dict]] |
The choices allowed by this command |
None |
channel_types |
Optional[list[Union[ChannelTypes, int]]] |
The types of channel allowed by this option |
None |
Source code in naff/models/naff/annotations/slash.py
def slash_channel_option(
description: str,
required: bool = False,
autocomplete: bool = False,
choices: List[Union["SlashCommandChoice", dict]] = None,
channel_types: Optional[list[Union["ChannelTypes", int]]] = None,
) -> Type["BaseChannel"]:
"""
Annotates an argument as a channel type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
choices: The choices allowed by this command
channel_types: The types of channel allowed by this option
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
choices=choices or [],
channel_types=channel_types,
type=models.OptionTypes.CHANNEL,
)
return option # type: ignore
function
slash_role_option(description, required, autocomplete, choices)
¶
Annotates an argument as a role type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
choices |
List[Union[SlashCommandChoice, dict]] |
The choices allowed by this command |
None |
Source code in naff/models/naff/annotations/slash.py
def slash_role_option(
description: str,
required: bool = False,
autocomplete: bool = False,
choices: List[Union["SlashCommandChoice", dict]] = None,
) -> Type["Role"]:
"""
Annotates an argument as a role type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
choices: The choices allowed by this command
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
choices=choices or [],
type=models.OptionTypes.ROLE,
)
return option # type: ignore
function
slash_mentionable_option(description, required, autocomplete, choices)
¶
Annotates an argument as a mentionable type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
autocomplete |
bool |
Use autocomplete for this option |
False |
choices |
List[Union[SlashCommandChoice, dict]] |
The choices allowed by this command |
None |
Source code in naff/models/naff/annotations/slash.py
def slash_mentionable_option(
description: str,
required: bool = False,
autocomplete: bool = False,
choices: List[Union["SlashCommandChoice", dict]] = None,
) -> Type[Union["Role", "BaseChannel", "User", "Member"]]:
"""
Annotates an argument as a mentionable type slash command option.
Args:
description: The description of your option
required: Is this option required?
autocomplete: Use autocomplete for this option
choices: The choices allowed by this command
"""
option = SlashCommandOption(
name="placeholder",
description=description,
required=required,
autocomplete=autocomplete,
choices=choices or [],
type=models.OptionTypes.MENTIONABLE,
)
return option # type: ignore
function
slash_attachment_option(description, required)
¶
Annotates an argument as an attachment type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description |
str |
The description of your option |
required |
required |
bool |
Is this option required? |
False |
Source code in naff/models/naff/annotations/slash.py
def slash_attachment_option(
description: str,
required: bool = False,
) -> Type["Attachment"]:
"""
Annotates an argument as an attachment type slash command option.
Args:
description: The description of your option
required: Is this option required?
"""
option = SlashCommandOption(
name="placeholder", description=description, required=required, type=models.OptionTypes.ATTACHMENT
)
return option # type: ignore