@@ -945,9 +945,7 @@ def command(self) -> Optional[Union['SlashCommand', 'MessageCommand', 'UserComma
945
945
@property
946
946
def focused_option (self ) -> 'InteractionDataOption' :
947
947
""":class:`~discord.InteractionDataOption`: Returns the currently focused option."""
948
- for option in self .data .options :
949
- if option .focused :
950
- return option
948
+ return self .focused
951
949
952
950
@property
953
951
def focused_option_name (self ) -> str :
@@ -1120,6 +1118,18 @@ def __new__(cls, *args, **kwargs):
1120
1118
1121
1119
1122
1120
class InteractionDataOption :
1121
+ """
1122
+ Represents a slash-command option passed via a command.
1123
+ By default, you only get in contact with this using :attr:`~discord.AutoCompleteInteraction.focused_option`.
1124
+
1125
+ Attributes
1126
+ -----------
1127
+ name: :class:`str`
1128
+ The name of the option
1129
+ type: :class:`~discord.OptionType`
1130
+ The type of the option
1131
+
1132
+ """
1123
1133
def __init__ (self , * , state , data , guild = None , ** kwargs ):
1124
1134
self ._state = state
1125
1135
self ._data = data
@@ -1130,6 +1140,7 @@ def __init__(self, *, state, data, guild=None, **kwargs):
1130
1140
1131
1141
@property
1132
1142
def value (self ) -> Optional [Union [str , int , float ]]:
1143
+ """Union[:class:`str`, :class:`int`, :class:`float`]: Returns the value of the option (what the user passed)"""
1133
1144
value = self ._data .get ('value' , None )
1134
1145
if value :
1135
1146
if isinstance (value , bool ): # because booleans are integers too
@@ -1144,10 +1155,12 @@ def value(self) -> Optional[Union[str, int, float]]:
1144
1155
1145
1156
@property
1146
1157
def focused (self ) -> bool :
1147
- return bool (self ._data .get ('focused' , False ))
1158
+ """:class:`bool`: Whether this option is currently focused (for autocomplete)"""
1159
+ return self ._data .get ('focused' , False )
1148
1160
1149
1161
@property
1150
1162
def options (self ) -> Optional [List ['InteractionDataOption' ]]:
1163
+ """Optional[List[:class:`InteractionDataOption`]]: For sub-command (groups) the sub-command or the actual options"""
1151
1164
options = self ._data .get ('options' , [])
1152
1165
return [InteractionDataOption (state = self ._state , data = option , guild = self ._guild ) for option in options ]
1153
1166
0 commit comments