
    i3                    R   d Z ddlmZ ddlmZmZmZmZmZm	Z	 ddl
mZ ddlmZmZmZ ddlmZ ddlmZmZ dd	lmZ d
Zer>ddlmZ ddlmZmZ 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# ddl$m%Z&m'Z(m)Z*m+Z, ddl-m.Z.  G d de          Z/ G d d          Z0 G d d          Z+dS )a:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

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.
    )annotations)TYPE_CHECKINGIterableOptionalSetListUnion   )Hashable)OnboardingModeOnboardingPromptTypetry_enum)PartialEmoji)cached_slot_propertyMISSING)utils)
OnboardingOnboardingPromptOnboardingPromptOption)Self)GuildChannel	Snowflake)Emoji)Guild)Role)Thread)PromptPromptOptionCreatePromptOptionr   )ConnectionStatec                      e Zd ZdZdZedeedd#dZd$dZed%d            Z	d&dZ
ed'd            Z ed          d(d            Z ed           d)d"            ZdS )*r   a  Represents a onboarding prompt option.

    This can be manually created for :meth:`Guild.edit_onboarding`.

    .. versionadded:: 2.6

    Parameters
    -----------
    title: :class:`str`
        The title of this prompt option.
    emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`]
        The emoji tied to this option. May be a custom emoji, or a unicode emoji. I
        f this is a string, it will be converted to a :class:`PartialEmoji`.
    description: Optional[:class:`str`]
        The description of this prompt option.
    channels: Iterable[Union[:class:`abc.Snowflake`, :class:`int`]]
        The channels the user will be added to if this option is selected.
    roles: Iterable[Union[:class:`abc.Snowflake`, :class:`int`]]
        The roles the user will be given if this option is selected.

    Attributes
    -----------
    id: :class:`int`
        The ID of this prompt option. If this was manually created then the ID will be ``0``.
    title: :class:`str`
        The title of this prompt option.
    description: Optional[:class:`str`]
        The description of this prompt option.
    emoji: Optional[Union[:class:`Emoji`, :class:`PartialEmoji`]]
        The emoji tied to this option. May be a custom emoji, or a unicode emoji.
    channel_ids: Set[:class:`int`]
        The IDs of the channels the user will be added to if this option is selected.
    role_ids: Set[:class:`int`]
        The IDs of the roles the user will be given if this option is selected.
    )	titleemojidescriptionidchannel_idsrole_ids_guild_cs_channels	_cs_rolesN)r#   r$   channelsrolesr"   strr#   Union[Emoji, PartialEmoji, str]r$   Optional[str]r+   Iterable[Union[Snowflake, int]]r,   returnNonec               T   d| _         || _        || _        t          |t                    rt          j        |          n|t          ur|nd | _        |t          urd |D             nt                      | _
        |t          urd |D             nt                      | _        d | _        d S )Nr   c                J    h | ] }t          |t                    s|j        n|!S  
isinstanceintr%   .0cs     Y/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/onboarding.py	<setcomp>z2OnboardingPromptOption.__init__.<locals>.<setcomp>}   s-    EEEqAs++2QTTEEE    c                J    h | ] }t          |t                    s|j        n|!S r5   r6   r9   s     r<   r=   z2OnboardingPromptOption.__init__.<locals>.<setcomp>   s-    "X"X"XQz!S/A/A#H144q"X"X"Xr>   )r%   r"   r$   r7   r-   r   from_strr   r#   setr&   r'   r(   )selfr"   r#   r$   r+   r,   s         r<   __init__zOnboardingPromptOption.__init__l   s     
*5,6uc,B,BoL!%(((QV^eQeQeko 	

 JRY`I`I`EEHEEEEfifkfk 	 ]bip\p\p"X"XRW"X"X"X"Xvyv{v{'+r>   c                8    d| j         d| j        d| j        dS )Nz<OnboardingPromptOption id= title=z emoji=>)r%   r"   r#   rB   s    r<   __repr__zOnboardingPromptOption.__repr__   s+    cTWcctzccTXT^ccccr>   dataPromptOptionPayloadstater    guildr   r   c          	         | |d         |d         d|v r|                     |d                   nt          d |d         D             d |d         D                       }||_        t          |d	                   |_        |S )
Nr"   r$   r#   c                ,    g | ]}t          |          S r5   r8   r:   r%   s     r<   
<listcomp>z4OnboardingPromptOption.from_dict.<locals>.<listcomp>   s    <<<"c"gg<<<r>   r&   c                ,    g | ]}t          |          S r5   rO   rP   s     r<   rQ   z4OnboardingPromptOption.from_dict.<locals>.<listcomp>   s    666r3r77666r>   r'   )r"   r$   r#   r+   r,   r%   )get_emoji_from_partial_payloadr   r(   r8   r%   clsrI   rK   rL   instances        r<   	from_dictz OnboardingPromptOption.from_dict   s    3w-]+IPTX%66tG}EEE^e<<](;<<<66T*%5666
 
 
  $t*oor>   CreatePromptOptionPayloadc                    | j         | j        t          | j                  t          | j                  d}| j        r>|                    | j                                                                                   |S )N)r"   r$   r&   r'   )	r"   r$   listr&   r'   r#   update_to_partial$_to_onboarding_prompt_option_payload)rB   ress     r<   to_dictzOnboardingPromptOption.to_dict   st     Z+ 011T]++	*
 *
 : 	ZJJ
..00VVXXYYY
r>   c                <    | j         t          d          | j         S )z:class:`Guild`: The guild this prompt option is related to.

        Raises
        -------
        ValueError
            If the prompt option was created manually.
        NNThis prompt does not have an associated guild because it was created manually.r(   
ValueErrorrG   s    r<   rL   zOnboardingPromptOption.guild   #     ;mnnn{r>   r)   !List[Union[GuildChannel, Thread]]c                    t          dt          | j        j        | j                            }t          j        |          S )a  List[Union[:class:`abc.GuildChannel`, :class:`Thread`]]: The list of channels which will be made visible if this option is selected.

        Raises
        -------
        ValueError
            IF the prompt option is manually created, therefore has no guild.
        N)filtermaprL   _resolve_channelr&   r   _uniquerB   its     r<   r+   zOnboardingPromptOption.channels   s5     D#dj94;KLLMM}R   r>   r*   
List[Role]c                    t          dt          | j        j        | j                            }t          j        |          S )zList[:class:`Role`]: The list of roles given to the user if this option is selected.

        Raises
        -------
        ValueError
            If the prompt option is manually created, therefore has no guild.
        N)rg   rh   rL   get_roler'   r   rj   rk   s     r<   r,   zOnboardingPromptOption.roles   s4     D#dj14=AABB}R   r>   )r"   r-   r#   r.   r$   r/   r+   r0   r,   r0   r1   r2   r1   r-   )rI   rJ   rK   r    rL   r   r1   r   )r1   rX   r1   r   r1   re   )r1   rm   )__name__
__module____qualname____doc__	__slots__r   rC   rH   classmethodrW   r_   propertyrL   r   r+   r,   r5   r>   r<   r   r   ;   s       " "H
I  29%)4;18, , , , , ,,d d d d 
 
 
 [
    
 
 
 X
 .))	! 	! 	! *)	! +&&	! 	! 	! '&	! 	! 	!r>   r   c                  p    e Zd ZdZdZddddd#dZd$dZed%d            Zd&dZ	e
d'd            Zd(d!Zd"S ))r   a  Represents a onboarding prompt.

    This can be manually created for :meth:`Guild.edit_onboarding`.

    .. versionadded:: 2.6

    Parameters
    -----------
    type: :class:`OnboardingPromptType`
        The type of this prompt.
    title: :class:`str`
        The title of this prompt.
    options: List[:class:`OnboardingPromptOption`]
        The options of this prompt.
    single_select: :class:`bool`
        Whether this prompt is single select.
        Defaults to ``True``.
    required: :class:`bool`
        Whether this prompt is required.
        Defaults to ``True``.
    in_onboarding: :class:`bool`
        Whether this prompt is in the onboarding flow.
        Defaults to ``True``.

    Attributes
    -----------
    id: :class:`int`
        The ID of this prompt. If this was manually created then the ID will be ``0``.
    type: :class:`OnboardingPromptType`
        The type of this prompt.
    title: :class:`str`
        The title of this prompt.
    options: List[:class:`OnboardingPromptOption`]
        The options of this prompt.
    single_select: :class:`bool`
        Whether this prompt is single select.
    required: :class:`bool`
        Whether this prompt is required.
    in_onboarding: :class:`bool`
        Whether this prompt is in the onboarding flow.
    r%   typer"   optionssingle_selectrequiredin_onboardingr(   T)r~   r   r   r|   r   r"   r-   r}   List[OnboardingPromptOption]r~   boolr   r   r1   r2   c               v    d| _         || _        || _        || _        || _        || _        || _        d | _        d S )Nr   r{   )rB   r|   r"   r}   r~   r   r   s          r<   rC   zOnboardingPrompt.__init__   sB     *.	
5<#0&#0'+r>   c                8    d| j         d| j        d| j        dS )Nz<OnboardingPrompt id=rE   z, type=rF   )r%   r"   r|   rG   s    r<   rH   zOnboardingPrompt.__repr__  s)    \tw\\\\di\\\\r>   rI   PromptPayloadrK   r    rL   r   r   c          	          | t          t          |d                   |d         fd|d         D             |d         |d         |d                   }t          |d	                   |_        |S )
Nr|   r"   c                J    g | ]}t                               |            S )rI   rK   rL   )r   rW   )r:   option_datarL   rK   s     r<   rQ   z.OnboardingPrompt.from_dict.<locals>.<listcomp>  s?        '00kV[0\\  r>   r}   r~   r   r   )r|   r"   r}   r~   r   r   r%   )r   r   r8   r%   rT   s     `` r<   rW   zOnboardingPrompt.from_dict  s    3.V==w-    #'	?   /*%/

 

 

 $t*oor>   r%   r8   c               p    || j         j        | j        d | j        D             | j        | j        | j        dS )Nc                6    g | ]}|                                 S r5   )r_   )r:   options     r<   rQ   z,OnboardingPrompt.to_dict.<locals>.<listcomp>'  s"    DDDV((DDDr>   )r%   r|   r"   r}   r~   r   r   )r|   valuer"   r}   r~   r   r   )rB   r%   s     r<   r_   zOnboardingPrompt.to_dict"  sD    IOZDDt|DDD!/!/
 
 	
r>   c                <    | j         t          d          | j         S )z:class:`Guild`: The guild this prompt is related to.

        Raises
        ------
        ValueError
            If the prompt was created manually.
        Nra   rb   rG   s    r<   rL   zOnboardingPrompt.guild-  rd   r>   	option_id Optional[OnboardingPromptOption]c               F    t          fd| j        D             d          S )zROptional[:class:`OnboardingPromptOption`]: The option with the given ID, if found.c              3  2   K   | ]}|j         k    |V  d S Nr%   )r:   r   r   s     r<   	<genexpr>z.OnboardingPrompt.get_option.<locals>.<genexpr><  /      QQ&)y:P:PV:P:P:P:PQQr>   N)nextr}   )rB   r   s    `r<   
get_optionzOnboardingPrompt.get_option:  +    QQQQ$,QQQSWXXXr>   N)r|   r   r"   r-   r}   r   r~   r   r   r   r   r   r1   r2   rp   )rI   r   rK   r    rL   r   r1   r   )r%   r8   r1   r   rq   )r   r8   r1   r   )rs   rt   ru   rv   rw   rC   rH   rx   rW   r_   ry   rL   r   r5   r>   r<   r   r      s        ( (T	I" #", , , , , ,(] ] ] ]    [	
 	
 	
 	
 
 
 
 X
Y Y Y Y Y Yr>   r   c                  X    e Zd ZdZdZddZddZ ed          dd            ZddZ	dS )r   aR  Represents a guild's onboarding configuration.

    .. versionadded:: 2.6

    Attributes
    -----------
    guild: :class:`Guild`
        The guild the onboarding configuration is for.
    prompts: List[:class:`OnboardingPrompt`]
        The list of prompts shown during the onboarding and customize community flows.
    default_channel_ids: Set[:class:`int`]
        The IDs of the channels exposed to a new user by default.
    enabled: :class:`bool`:
        Whether onboarding is enabled in this guild.
    mode: :class:`OnboardingMode`
        The mode of onboarding for this guild.
    )_state_cs_default_channelsrL   promptsdefault_channel_idsenabledmoderI   OnboardingPayloadrL   r   rK   r    r1   r2   c                   | _         | _        d |d         D             | _        fd|d         D             | _        |d         | _        t          t          |                    dd                    | _        d S )Nc                ,    h | ]}t          |          S r5   rO   )r:   
channel_ids     r<   r=   z&Onboarding.__init__.<locals>.<setcomp>_  s    -l-l-l*c*oo-l-l-lr>   r   c                J    g | ]}t                               |            S r   )r   rW   )r:   prompt_datarL   rK   s     r<   rQ   z'Onboarding.__init__.<locals>.<listcomp>`  s<     0
 0
 0
Wb&&KuE&RR0
 0
 0
r>   r   r   r   r   )	r   rL   r   r   r   r   r   getr   )rB   rI   rL   rK   s     ``r<   rC   zOnboarding.__init__\  s    ',!
-l-lPTUjPk-l-l-l 0
 0
 0
 0
 0
fjktfu0
 0
 0
 ")_$,^TXXfa=P=P$Q$Q			r>   r-   c                8    d| j         d| j        d| j        dS )Nz<Onboarding guild=z	 enabled=z mode=rF   )rL   r   r   rG   s    r<   rH   zOnboarding.__repr__f  s+    _DJ__4<__QUQZ____r>   r   re   c                    t          dt          | j        j        | j                            }t          j        |          S )zoList[Union[:class:`abc.GuildChannel`, :class:`Thread`]]: The list of channels exposed to a new user by default.N)rg   rh   rL   ri   r   r   rj   rk   s     r<   default_channelszOnboarding.default_channelsi  s5     D#dj94;STTUU}R   r>   	prompt_idr8   Optional[OnboardingPrompt]c               F    t          fd| j        D             d          S )zLOptional[:class:`OnboardingPrompt`]: The prompt with the given ID, if found.c              3  2   K   | ]}|j         k    |V  d S r   r   )r:   promptr   s     r<   r   z(Onboarding.get_prompt.<locals>.<genexpr>q  r   r>   N)r   r   )rB   r   s    `r<   
get_promptzOnboarding.get_prompto  r   r>   N)rI   r   rL   r   rK   r    r1   r2   rp   rr   )r   r8   r1   r   )
rs   rt   ru   rv   rw   rC   rH   r   r   r   r5   r>   r<   r   r   ?  s         $IR R R R` ` ` ` 011! ! ! 21!
Y Y Y Y Y Yr>   r   N)1rv   
__future__r   typingr   r   r   r   r   r	   mixinsr   enumsr   r   r   partial_emojir   r   r   r    __all__typing_extensionsr   abcr   r   r#   r   rL   r   roler   threadsr   types.onboardingr   r   r   rJ   r   rX   r   r   rK   r    r   r   r5   r>   r<   <module>r      sL   0 # " " " " " F F F F F F F F F F F F F F F F       A A A A A A A A A A ' ' ' ' ' ' 0 0 0 0 0 0 0 0        '&&&&&&,,,,,,,,++++++            '&&&&&G! G! G! G! G!X G! G! G!TwY wY wY wY wY wY wY wYt2Y 2Y 2Y 2Y 2Y 2Y 2Y 2Y 2Y 2Yr>   