
    cjhLI                       d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	m
Z
mZmZ ddlmZmZ ddlmZmZmZmZmZmZmZ dd	lmZ ddlmZ dd
lmZ ddlmZmZ er]ddlm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z( eee)   ee*   ee+   ee,   ee   ee   ee"   ee(   ee$   ee&   ee   ee ee    ee   ee   f   Z-dZ.eej^                  eej`                  eejb                  eejd                  eejf                  eejh                  eejj                  iZ6 ejn                  e8      Z9 G d d      Z: G d d      Z; G d d      Z<ddZ=y)aF  
The MIT License (MIT)

Copyright (c) 2021-present Pycord Development

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotationsN)Enum)TYPE_CHECKINGLiteralOptionalTypeUnion   )GuildChannelMentionable)CategoryChannel	DMChannelForumChannelStageChannelTextChannelThreadVoiceChannel)ChannelType)SlashCommandOptionType)MISSINGbasic_autocomplete	Converter)Member)
Attachment)Role)User)ThreadOptionOptionOptionChoiceoptionc                      e Zd ZdZddZy)r   a  Represents a class that can be passed as the ``input_type`` for an :class:`Option` class.

    .. versionadded:: 2.0

    Parameters
    ----------
    thread_type: Literal["public", "private", "news"]
        The thread type to expect for this options input.
    c                x    t         j                  t         j                  t         j                  d}||   | _        y )N)publicprivatenews)r   public_threadprivate_threadnews_thread_type)selfthread_typetype_maps      K/var/www/html/venv/lib/python3.12/site-packages/discord/commands/options.py__init__zThreadOption.__init__h   s2    !//"11++

 k*
    N)r,   z$Literal['public', 'private', 'news'])__name__
__module____qualname____doc__r/    r0   r.   r   r   ]   s    +r0   r   c                  P    e Zd ZU dZded<   dZded<   edf	 	 	 	 	 d
dZddZd	 Z	y)r   a  Represents a selectable option for a slash command.

    Attributes
    ----------
    input_type: Union[Type[:class:`str`], Type[:class:`bool`], Type[:class:`int`], Type[:class:`float`], Type[:class:`.abc.GuildChannel`], Type[:class:`Thread`], Type[:class:`Member`], Type[:class:`User`], Type[:class:`Attachment`], Type[:class:`Role`], Type[:class:`.abc.Mentionable`], :class:`SlashCommandOptionType`, Type[:class:`.ext.commands.Converter`], Type[:class:`enums.Enum`], Type[:class:`Enum`]]
        The type of input that is expected for this option. This can be a :class:`SlashCommandOptionType`,
        an associated class, a channel type, a :class:`Converter`, a converter class or an :class:`enum.Enum`.
        If a :class:`enum.Enum` is used and it has up to 25 values, :attr:`choices` will be automatically filled. If the :class:`enum.Enum` has more than 25 values, :attr:`autocomplete` will be implemented with :func:`discord.utils.basic_autocomplete` instead.
    name: :class:`str`
        The name of this option visible in the UI.
        Inherits from the variable name if not provided as a parameter.
    description: Optional[:class:`str`]
        The description of this option.
        Must be 100 characters or fewer. If :attr:`input_type` is a :class:`enum.Enum` and :attr:`description` is not specified, :attr:`input_type`'s docstring will be used.
    choices: Optional[List[Union[:class:`Any`, :class:`OptionChoice`]]]
        The list of available choices for this option.
        Can be a list of values or :class:`OptionChoice` objects (which represent a name:value pair).
        If provided, the input from the user must match one of the choices in the list.
    required: Optional[:class:`bool`]
        Whether this option is required.
    default: Optional[:class:`Any`]
        The default value for this option. If provided, ``required`` will be considered ``False``.
    min_value: Optional[:class:`int`]
        The minimum value that can be entered.
        Only applies to Options with an :attr:`.input_type` of :class:`int` or :class:`float`.
    max_value: Optional[:class:`int`]
        The maximum value that can be entered.
        Only applies to Options with an :attr:`.input_type` of :class:`int` or :class:`float`.
    min_length: Optional[:class:`int`]
        The minimum length of the string that can be entered. Must be between 0 and 6000 (inclusive).
        Only applies to Options with an :attr:`input_type` of :class:`str`.
    max_length: Optional[:class:`int`]
        The maximum length of the string that can be entered. Must be between 1 and 6000 (inclusive).
        Only applies to Options with an :attr:`input_type` of :class:`str`.
    autocomplete: Optional[Callable[[:class:`.AutocompleteContext`], Awaitable[Union[Iterable[:class:`.OptionChoice`], Iterable[:class:`str`], Iterable[:class:`int`], Iterable[:class:`float`]]]]]
        The autocomplete handler for the option. Accepts a callable (sync or async)
        that takes a single argument of :class:`AutocompleteContext`.
        The callable must return an iterable of :class:`str` or :class:`OptionChoice`.
        Alternatively, :func:`discord.utils.basic_autocomplete` may be used in place of the callable.

        .. note::

            Does not validate the input value against the autocomplete results.
    channel_types: list[:class:`discord.ChannelType`] | None
        A list of channel types that can be selected in this option.
        Only applies to Options with an :attr:`input_type` of :class:`discord.SlashCommandOptionType.channel`.
        If this argument is used, :attr:`input_type` will be ignored.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this option. The values of this should be ``"locale": "name"``.
        See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    description_localizations: Dict[:class:`str`, :class:`str`]
        The description localizations for this option. The values of this should be ``"locale": "description"``.
        See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.

    Examples
    --------
    Basic usage: ::

        @bot.slash_command(guild_ids=[...])
        async def hello(
            ctx: discord.ApplicationContext,
            name: Option(str, "Enter your name"),
            age: Option(int, "Enter your age", min_value=1, max_value=99, default=18)
            # passing the default value makes an argument optional
            # you also can create optional argument using:
            # age: Option(int, "Enter your age") = 18
        ):
            await ctx.respond(f"Hello! Your name is {name} and you are {age} years old.")

    .. versionadded:: 2.0
    r   
input_typeNz"Converter | type[Converter] | None	converterc          	        |j                  dd       | _        | j                  t        | j                        | _        | j                  | _        || _        g }t        |t              }|r>t        |t        t        f      r'|Xt        j                  |j                        }|r7t        |      dkD  r)|d d dz   }t        j                  d| j                  |       |D cg c]"  }t!        |j                  |j"                        $ }}|d   j"                  j$                  t'        fd|D              r-t)        j*                  |d   j"                  j$                        }nF|D cg c]+  }t!        |j                  t        |j"                              - }}t(        j,                  }|xs d| _        |j                  d	g       | _        t        |t(              r|| _        nd
dlm} t        ||      s|r4t        ||      r(|| _        t        | _        t(        j,                  | _        n	 t)        j*                  |      | _        | j2                  t(        j:                  k(  r{t        | j                  t<              s&t?        |d      r|j@                  | _        n|f| _        | j0                  s/| j                  D cg c]  }|tB        ur	tD        |    c}| _        	 d|vr|j                  dd      nd| _&        |j                  dd       | _'        |j                  dd       | _(        t        |      dkD  rNg | _)        |D ]  }t        |j"                        |_         tU        |      | _(        t(        j,                  | _        nD|xs; |j                  dg       D cg c]  }t        |t               r|n
t!        |      ! c}| _)        | j2                  t(        jV                  k(  rtX        t        d       f}tZ        tX           }ne| j2                  t(        j\                  k(  r1tX        t^        t        d       f}tZ        t`        tX        t^        f      }nt        d       f}t        d       }| j2                  t(        j,                  k(  rtX        t        d       f}tZ        tX           }nt        d       f}t        d       }|j                  dd       | _1        |j                  dd       | _2        |j                  dd       | _3        |j                  dd       | _4        | j2                  t(        jV                  k7  r@| j2                  t(        j\                  k7  r#| jb                  s| jd                  rtk        d      | j2                  t(        j,                  k7  r#| jf                  s| jh                  rtk        d      | jb                  Et        | jb                  |      s/tG        d| dt        | jb                        jl                   d      | jd                  Et        | jd                  |      s/tG        d| dt        | jd                        jl                   d      | jf                  nt        | jf                  |      s/tG        d| dt        | jf                        jl                   d      | jf                  dk  s| jf                  d kD  rtk        d!      | jh                  nt        | jh                  |      s/tG        d| d"t        | jh                        jl                   d      | jh                  d#k  s| jh                  d kD  rtk        d$      |j                  d%tn              | _8        |j                  d&tn              | _9        |tG        d'      y c c}w c c}w c c}w # tF        $ rA}	d
dl$m%}
 ||
vr|	|
|   | _        t        | _        t(        j,                  | _        Y d }	~	d }	~	ww xY wc c}w )(Nnamed   a   z...zZOption %s's description was truncated due to Enum %s's docstring exceeding 100 characters.r   c              3  J   K   | ]  }t        |j                          y wN)
isinstancevalue).0elemvalue_classs     r.   	<genexpr>z"Option.__init__.<locals>.<genexpr>   s     P4:djj+6Ps    #zNo description providedchannel_typesr
   r   __args__)CONVERTER_MAPPINGdefaultrequiredTFautocomplete   choices	min_value	max_value
min_length
max_lengthzzOption does not take min_value or max_value if not of type SlashCommandOptionType.integer or SlashCommandOptionType.numberz@Option does not take min_length or max_length if not of type strz	Expected z for min_value, got ""z for max_value, got "z for min_length, got "ip  z1min_length must be between 0 and 6000 (inclusive)z for max_length, got "   z.max_length must between 1 and 6000 (inclusive)name_localizationsdescription_localizationszinput_type cannot be NoneType.):popr:   str_parameter_name	_raw_typer?   type
issubclassr   DiscordEnuminspectcleandocr4   len_logwarningr    r@   	__class__allr   from_datatypestringdescriptionrE   r7   ext.commandsr   r8   channeltuplehasattrrF   r   CHANNEL_TYPE_MAP	TypeErrorext.commands.converterrG   rI   rH   rJ   rL   r   integerintr   numberfloatr	   rM   rN   rO   rP   AttributeErrorr1   r   rS   rT   )r+   r7   re   kwargsenum_choicesinput_type_is_classer   texcrG   ominmax_typesminmax_typehintminmax_length_typesminmax_length_typehintrC   s                   @r.   r/   zOption.__init__   s    !'

64 8	99 DIIDI#yy,6(T::j4:M#N"%..z/A/AB3{#3c#9"-cr"2U":KLLt		"
 DNNaL9NLN&q///99KP<PP3AA O))33
 MWWqQVVS\ BWW3::
&C*C06

?B0Oj"89(DO0 :y1&z95!+!$"8"?"?&<&J&J:&VDO *@*H*HH)$..%@&z:>1;1D1D2<#11 *.2$%#$L#8 !1 32D. -6V,CFJJz4( 	 zz)T2"JJ~t<|r!/1DL! 'agg,' 2< @D4;;DO/; 0Ir2@  <0l1oE@DL
 ??4<<<d,L&smO__ 6 = ==T
3L&uS%Z'89O J=L"4jO??4;;;#&T
"3%-c]"#':-%)$Z"-3ZZT-J-3ZZT-J&,jjt&D&,jjt&D OO5===#9#@#@@4>> R  ??4;;;OOt R  >>%j.VO, -$..)22316  >>%j.VO, -$..)22316 
 ??&doo/BC 67 8!$//2;;<A?  "doo&<$G  ??&doo/BC 67 8!$//2;;<A?  "doo&<$%UVV"(**-A7"K)/'*
& <== [ O  XL2! ! DJ!)::!	%6z%BDN%(DN&<&C&CDOODD@s0   !'^(0^-^  >^$_- 	_*)6_%%_*c           	        | j                   | j                  | j                  j                  | j                  | j
                  D cg c]  }|j                          c}t        | j                        d}| j                  t        ur| j                  |d<   | j                  t        ur| j                  |d<   | j                  r'| j                  D cg c]  }|j                   c}|d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                   | j                   |d<   |S c c}w c c}w )	N)r:   re   rY   rI   rL   rJ   rS   rT   rE   rM   rN   rO   rP   )r:   re   r7   r@   rI   rL   to_dictboolrJ   rS   r   rT   rE   rM   rN   rO   rP   )r+   cas_dictrv   s       r.   r~   zOption.to_dictb  s+   II++OO))-1\\:		: !2!23
 ""'1,0,C,CG()))8373Q3QG/09=9K9K'LA'LGO$>>%#'>>GK >>%#'>>GK ??&$(OOGL!??&$(OOGL!% ; (Ms   EEc                P    d| j                   j                   d| j                   dS )Nz<discord.commands.z name=>)ra   r1   r:   )r+   s    r.   __repr__zOption.__repr__|  s&    #DNN$;$;#<F499+QOOr0   )re   z
str | Noner7   	InputTypereturnNone)r   dict)
r1   r2   r3   r4   __annotations__r8   rV   r/   r~   r   r5   r0   r.   r   r   q   sP    FP '&48I18 '*c>;Ec>#c>	c>J4Pr0   r   c                  0    e Zd ZdZdef	 	 	 	 	 ddZddZy)r    a  
    Represents a name:value pairing for a selected :class:`.Option`.

    .. versionadded:: 2.0

    Attributes
    ----------
    name: :class:`str`
        The name of the choice. Shown in the UI when selecting an option.
    value: Optional[Union[:class:`str`, :class:`int`, :class:`float`]]
        The value of the choice. If not provided, will use the value of ``name``.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this choice. The values of this should be ``"locale": "name"``.
        See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    Nc                H    t        |      | _        ||n|| _        || _        y r>   )rV   r:   r@   rS   )r+   r:   r@   rS   s       r.   r/   zOptionChoice.__init__  s%     I	#/UT
"4r0   c                z    | j                   | j                  d}| j                  t        ur| j                  |d<   |S )N)r:   r@   rS   )r:   r@   rS   r   )r+   r   s     r.   r~   zOptionChoice.to_dict  s8    99tzz:""'1,0,C,CG()r0   )r:   rV   r@   zstr | int | float | NonerS   zdict[str, str])r   zdict[str, str | int | float])r1   r2   r3   r4   r   r/   r~   r5   r0   r.   r    r      s5    & +/-4	55 (5 +	5r0   r    c                      fd}|S )a<  A decorator that can be used instead of typehinting :class:`.Option`.

    .. versionadded:: 2.0

    Attributes
    ----------
    parameter_name: :class:`str`
        The name of the target function parameter this option is mapped to.
        This allows you to have a separate UI ``name`` and parameter name.
    c                    j                  dd       xs }j                  dd       xs$ xs  | j                  j                  |t              }t	        |fdi| j                  |<   | S )Nparameter_namerY   r:   )rU   r   getrV   r   )funcresolved_nameityper7   rr   r:   s      r.   	decoratorzoption.<locals>.decorator  su    

#3T:BdJJvt$ <<##''s; 	
 /5U.P.P.P]+r0   r5   )r:   r7   rr   r   s   ``` r.   r!   r!     s     r0   r>   )>r4   
__future__r   r\   loggingenumr   typingr   r   r   r   r	   abcr   r   rg   r   r   r   r   r   r   r   enumsr   r[   r   utilsr   r   rf   r   memberr   messager   roler   userr   rV   r   rn   rp   r   __all__textvoicestage_voicecategoryr'   forumr%   rj   	getLoggerr1   r_   r   r   r    r!   r5   r0   r.   <module>r      sf  0 #    @ @ +     ' * /($S	T
S	U\VVT
ZT
[YT
[	I& !!+##+))[))
K%%+##{""  w"+ +(LP LP^   Fr0   