|
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
|
@@ -176,6 +176,36 @@ def voice_client(self) -> Optional[VoiceProtocol]:
|
176 | 176 | def response(self) -> InteractionResponse:
|
177 | 177 | return self.interaction.response
|
178 | 178 |
|
| 179 | + @property |
| 180 | + def selected_options(self) -> Optional[List[Dict]]: |
| 181 | + """The options and values that were selected by the user when sending the command. |
| 182 | +
|
| 183 | + Returns |
| 184 | + ------- |
| 185 | + Optional[List[Dict]] |
| 186 | + A dictionary containing the options and values that were selected by the user when the command was processed, if applicable. |
| 187 | + """ |
| 188 | + if "options" in self.interaction.data: |
| 189 | + return self.interaction.data["options"] |
| 190 | + return None |
| 191 | + |
| 192 | + @property |
| 193 | + def unselected_options(self) -> Optional[List[Option]]: |
| 194 | + """The options that were not provided by the user when sending the command. |
| 195 | +
|
| 196 | + Returns |
| 197 | + ------- |
| 198 | + Optional[List[:class:`.Option`]] |
| 199 | + A list of Option objects (if any) that were not selected by the user when the command was processed. |
| 200 | + """ |
| 201 | + if self.command.options is not None: # type: ignore |
| 202 | + return [ |
| 203 | + option |
| 204 | + for option in self.command.options # type: ignore |
| 205 | + if option.to_dict()["name"] not in [opt["name"] for opt in self.selected_options] |
| 206 | + ] |
| 207 | + return None |
| 208 | + |
179 | 209 | @property
|
180 | 210 | def respond(self) -> Callable[..., Awaitable[Union[Interaction, WebhookMessage]]]:
|
181 | 211 | """Callable[..., Union[:class:`~.Interaction`, :class:`~.Webhook`]]: Sends either a response
|
|
0 commit comments