From 6ce3e5831fbd29526dddb8fe9bf924aba3050c52 Mon Sep 17 00:00:00 2001 From: Rouven Date: Mon, 11 Jul 2022 08:59:24 +0200 Subject: [PATCH 1/2] implement min_length and max_length --- flask_discord_interactions/models/option.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flask_discord_interactions/models/option.py b/flask_discord_interactions/models/option.py index a39987d..d5182ff 100644 --- a/flask_discord_interactions/models/option.py +++ b/flask_discord_interactions/models/option.py @@ -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. @@ -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 @@ -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: From 83ab88d6c26f22662734a5f48137fa7f02158eb1 Mon Sep 17 00:00:00 2001 From: Brooke Chalmers Date: Mon, 11 Jul 2022 21:45:56 -0400 Subject: [PATCH 2/2] add example --- examples/options.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/options.py b/examples/options.py index 69d3603..ba564a9 100644 --- a/examples/options.py +++ b/examples/options.py @@ -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",