|
1 |
| -import logging |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +The MIT License (MIT) |
| 5 | +
|
| 6 | +Copyright (c) 2021-present mccoderpy |
| 7 | +
|
| 8 | +Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | +copy of this software and associated documentation files (the "Software"), |
| 10 | +to deal in the Software without restriction, including without limitation |
| 11 | +the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | +and/or sell copies of the Software, and to permit persons to whom the |
| 13 | +Software is furnished to do so, subject to the following conditions: |
| 14 | +
|
| 15 | +The above copyright notice and this permission notice shall be included in |
| 16 | +all copies or substantial portions of the Software. |
| 17 | +
|
| 18 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 | +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 24 | +DEALINGS IN THE SOFTWARE. |
| 25 | +""" |
| 26 | +from __future__ import annotations |
| 27 | + |
| 28 | +from typing import ( |
| 29 | + Union, |
| 30 | + Optional, |
| 31 | + List, |
| 32 | + Dict, |
| 33 | + Any, |
| 34 | + TYPE_CHECKING |
| 35 | +) |
2 | 36 |
|
3 |
| -from . import abc |
| 37 | +import logging |
4 | 38 |
|
5 |
| -from . import utils |
| 39 | +from . import abc, utils |
6 | 40 | from .role import Role
|
7 | 41 | from .user import User
|
8 | 42 | from .file import File
|
|
17 | 51 | from typing_extensions import Literal
|
18 | 52 | from .message import Message, Attachment
|
19 | 53 | from .application_commands import OptionType, SlashCommandOptionChoice
|
20 |
| -from typing import (Union, |
21 |
| - List, |
22 |
| - Optional, |
23 |
| - Dict, |
24 |
| - Any, |
25 |
| - TYPE_CHECKING |
26 |
| -) |
27 | 54 |
|
28 | 55 | from .components import Button, SelectMenu, ActionRow, Modal, TextInput
|
29 | 56 | from .channel import _channel_factory, TextChannel, VoiceChannel, DMChannel, ThreadChannel
|
@@ -832,7 +859,7 @@ def __init__(self, *args, **kwargs):
|
832 | 859 |
|
833 | 860 | @property
|
834 | 861 | def command(self) -> Optional[Union['SlashCommand', 'MessageCommand', 'UserCommand']]:
|
835 |
| - """Optional[:class:`~discord.ApplicationCommand`]: The application-command that was invoked if any.""" |
| 862 | + """Optional[:class:`~discord.ApplicationCommand`]: The application-command that was invoked.""" |
836 | 863 | if getattr(self, '_command', None) is not None:
|
837 | 864 | return self._command
|
838 | 865 | return self._state._get_client()._get_application_command(self.data.id) \
|
@@ -904,8 +931,17 @@ async def defer(self,
|
904 | 931 |
|
905 | 932 | class AutocompleteInteraction(BaseInteraction):
|
906 | 933 | """
|
907 |
| - Represents the data of an interaction that will be received when autocomplete for a :class:`discord.SlashCommandOption` with :attr:`~discord.SlashCommandOption.autocomplete` set to :obj:`True`. |
| 934 | + Represents the data of an interaction that will be received when autocomplete for a :class:`~discord.SlashCommandOption` with :attr:`~discord.SlashCommandOption.autocomplete` set to :obj:`True`. |
908 | 935 | """
|
| 936 | + |
| 937 | + @property |
| 938 | + def command(self) -> Optional[Union['SlashCommand', 'MessageCommand', 'UserCommand']]: |
| 939 | + """Optional[:class:`~discord.SlashCommand`]: The slash-command for wich autocomplete was triggered.""" |
| 940 | + if getattr(self, '_command', None) is not None: |
| 941 | + return self._command |
| 942 | + return self._state._get_client()._get_application_command(self.data.id) \ |
| 943 | + if (self.type.ApplicationCommand or self.type.ApplicationCommandAutocomplete) else None |
| 944 | + |
909 | 945 | @property
|
910 | 946 | def focused_option(self) -> 'InteractionDataOption':
|
911 | 947 | """:class:`~discord.InteractionDataOption`: Returns the currently focused option."""
|
|
0 commit comments