@@ -171,7 +171,7 @@ def create_option(name: str,
171
171
}
172
172
173
173
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 :
175
175
"""
176
176
Generates a list of options from the type hints of a command.
177
177
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.") -
181
181
182
182
:param function: The function callable of the command.
183
183
:param description: The default argument description.
184
+ :param connector: Kwargs connector of the command.
184
185
"""
185
186
options = []
187
+ if connector :
188
+ connector = {y : x for x , y in connector .items ()} # Flip connector.
186
189
params = iter (inspect .signature (function ).parameters .values ())
187
190
if next (params ).name in ("self" , "cls" ):
188
191
# Skip 1. (+ 2.) parameter, self/cls and ctx
@@ -204,7 +207,8 @@ def generate_options(function: Callable, description: str = "No description.") -
204
207
required = not args [- 1 ] is type (None )
205
208
206
209
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 ))
208
212
209
213
return options
210
214
0 commit comments