Skip to content

Commit

Permalink
Merge pull request #111 from therealr5/feature/string-length
Browse files Browse the repository at this point in the history
implement min_length and max_length
  • Loading branch information
breqdev authored Jul 12, 2022
2 parents 5815714 + 83ab88d commit 2c09978
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ def do_read():
@discord.command(
options=[
Option(
name="message", type=str, description="The message to repeat", required=True
name="message",
type=str,
description="The message to repeat",
required=True,
min_length=2,
max_length=8,
),
Option(
name="times",
Expand Down
8 changes: 8 additions & 0 deletions flask_discord_interactions/models/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class Option:
The minimum value of the option if the option is numeric.
max_value
The maximum value of the option if the option is numeric.
min_length
Minimum allowed length for string type options.
max_value
Maximum allowed length for string type options.
autocomplete
Whether the option should be autocompleted. Defaults to ``False``.
Set to ``True`` if you have an autocomplete handler for this command.
Expand All @@ -71,6 +75,8 @@ class Option:
channel_types: Optional[list] = None
min_value: Optional[int] = None
max_value: Optional[int] = None
min_length: Optional[int] = None
max_length: Optional[int] = None
name_localizations: Optional[dict] = None
description_localizations: Optional[dict] = None

Expand Down Expand Up @@ -121,6 +127,8 @@ def dump(self):
"channel_types": self.channel_types,
"min_value": self.min_value,
"max_value": self.max_value,
"min_length": self.min_length,
"max_length": self.max_length,
"autocomplete": self.autocomplete,
}
if self.choices is not None:
Expand Down

0 comments on commit 2c09978

Please sign in to comment.