|
24 | 24 | """
|
25 | 25 | from __future__ import annotations
|
26 | 26 |
|
27 |
| -from typing import TYPE_CHECKING, Optional, TypeVar, Union |
| 27 | +from typing import TYPE_CHECKING, Optional, TypeVar, Union, Dict, List |
28 | 28 |
|
29 | 29 | import discord.abc
|
30 | 30 | from discord.interactions import InteractionMessage
|
@@ -172,6 +172,26 @@ def voice_client(self) -> Optional[VoiceProtocol]:
|
172 | 172 | def response(self) -> InteractionResponse:
|
173 | 173 | return self.interaction.response
|
174 | 174 |
|
| 175 | + @property |
| 176 | + def selected_options(self) -> Optional[List[Dict]]: |
| 177 | + """Returns a dictionary containing the options and values that were selected by the user, if applicable.""" |
| 178 | + if "options" in self.interaction.data: |
| 179 | + return self.interaction.data["options"] |
| 180 | + return None |
| 181 | + |
| 182 | + @property |
| 183 | + def unselected_options(self) -> Optional[List[Dict]]: |
| 184 | + """Returns a dictionary containing the options that were not selected by the user, if applicable.""" |
| 185 | + if self.command.options is not None: # type: ignore |
| 186 | + selected = [opt["name"] for opt in self.selected_options] |
| 187 | + return [ |
| 188 | + {"name": option.to_dict()["name"]} |
| 189 | + for option in self.command.options # type: ignore |
| 190 | + if option.to_dict()["name"] not in selected |
| 191 | + ] |
| 192 | + |
| 193 | + return None |
| 194 | + |
175 | 195 | @property
|
176 | 196 | def respond(self) -> Callable[..., Awaitable[Union[Interaction, WebhookMessage]]]:
|
177 | 197 | """Callable[..., Union[:class:`~.Interaction`, :class:`~.Webhook`]]: Sends either a response
|
|
0 commit comments