@@ -171,7 +171,7 @@ def create_option(name: str,
171171 }
172172
173173
174- def generate_options (function : Callable , description : str = "No description." ) -> list :
174+ def generate_options (function : Callable , description : str = "No description." , connector : dict = None ) -> list :
175175 """
176176 Generates a list of options from the type hints of a command.
177177 You currently can type hint: str, int, bool, discord.User, discord.Channel, discord.Role
@@ -181,8 +181,11 @@ def generate_options(function: Callable, description: str = "No description.") -
181181
182182 :param function: The function callable of the command.
183183 :param description: The default argument description.
184+ :param connector: Kwargs connector of the command.
184185 """
185186 options = []
187+ if connector :
188+ connector = {y : x for x , y in connector .items ()} # Flip connector.
186189 params = iter (inspect .signature (function ).parameters .values ())
187190 if next (params ).name in ("self" , "cls" ):
188191 # Skip 1. (+ 2.) parameter, self/cls and ctx
@@ -204,7 +207,8 @@ def generate_options(function: Callable, description: str = "No description.") -
204207 required = not args [- 1 ] is type (None )
205208
206209 option_type = SlashCommandOptionType .from_type (param .annotation ) or SlashCommandOptionType .STRING
207- options .append (create_option (param .name , description or "No Description." , option_type , required ))
210+ name = param .name if not connector else connector [param .name ]
211+ options .append (create_option (name , description or "No Description." , option_type , required ))
208212
209213 return options
210214
0 commit comments