
    cjhA                       d Z ddlmZ ddlmZmZ ddlmZmZm	Z	 ddl
mZ ddlmZmZmZmZ er:ddlmZ dd	l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 ddlmZ ddlm Z! ddlm"Z# dZ$ G d d      Z" G d d      Z  G 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.
    )annotations)TYPE_CHECKINGAny   )OnboardingMode
PromptTypetry_enum)PartialEmoji)MISSINGcached_propertygenerate_snowflakeget)	Snowflake)ForumChannelTextChannelVoiceChannel)Emoji)Guild)Object)
Onboarding)OnboardingPrompt)PromptOption)r   r   r   c                  Z    e Zd ZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZd Zd	dZed
d       Zy)r   a  Represents an onboarding prompt option displayed in :class:`OnboardingPrompt`.

    .. versionadded:: 2.5

    Attributes
    ----------

    id: :class:`int`
        The id of the prompt option.
    channels: List[:class:`Snowflake`]
        The channels assigned to the user when they select this option.
    roles: List[:class:`Snowflake`]
        The roles assigned to the user when they select this option.
    emoji: Union[:class:`Emoji`, :class:`PartialEmoji`]
        The emoji displayed with the option.
    title: :class:`str`
        The option's title.
    description: Optional[:class:`str`]
        The option's description.
    Nc                    |rt        |      n	t               | _        || _        |xs g | _        |xs g | _        |xs d | _        || _        y N)intr   idtitlechannelsrolesdescriptionemoji)selfr   r   r    r!   r"   r   s          E/var/www/html/venv/lib/python3.12/site-packages/discord/onboarding.py__init__zPromptOption.__init__I   sH     #%s2w*<*>
)1R&+kr
'2':d27
    c           	     p    d| j                    d| j                  d| j                  d| j                  d	S )Nz<PromptOption id= title=z description=z emoji=>)r   r   r!   r"   r#   s    r$   __repr__zPromptOption.__repr__Z   s<    "477)74::.dN^N^Maahimisishvvwxxr&   c                   | j                   | j                  | j                  D cg c]  }|j                   c}| j                  D cg c]  }|j                   c}t        | j                        d}| j                  r| j                  j                  rt        | j                  j                        nd | j                  j                  | j                  j                  d|d<   | j                  j                  |d<   | j                  j                  r;t        | j                  j                        |d<   | j                  j                  |d<   |S c c}w c c}w )N)r   r!   channel_idsrole_idsr   )r   nameanimatedr"   
emoji_nameemoji_idemoji_animated)	r   r!   r   r   r    strr"   r/   r0   )r#   channelroledict_s       r$   to_dictzPromptOption.to_dict]   s    ZZ++6:mmD7GJJD-1ZZ8T8dgg,&
 ::,0JJMMc$**--(t

 JJ//E'N
 #'**//E,zz}}$'

$6j!*.***=*=&' E8s   EE
c                   |j                  dd      }|j                  dg       D cg c]  }t        |       }}|D cg c]  }|j                  |       }}|j                  dg       D cg c]  }t        |       }}|D cg c]  }|j                  |       }	}|j                  d      }
|j                  d      }|j                  d      xs i }d|v rGt	        j
                  |      }|j                  r(t        |j                  |j                  	      xs |}nd } | ||	|
|||
      S c c}w c c}w c c}w c c}w )Nr   r   r-   r.   r   r!   r"   r/   r   )r   r    r   r!   r"   r   )r   r   get_channelget_roler
   	from_dictr   emojis)clsdataguildr   
channel_idr-   r   role_idr.   r    r   r!   _emojir"   s                 r$   
_from_dictzPromptOption._from_dictr   s#   XXdA9=-QS9TU:s:UUDOPjE%%j1PP04R0HIWCLII8@AW(AA!hh}-!%'!2!8bV **62ExxELLUXX6?%EHEK_dikll! VPIAs   D1D6-D;E )NNNNN)r   r4   r   list[Snowflake] | Noner    rF   r!   
str | Noner"   zEmoji | PartialEmoji | Noner   
int | None)returnPromptOptionPayload)r@   rJ   rA   r   rI   r   	__name__
__module____qualname____doc__r%   r+   r8   classmethodrE    r&   r$   r   r   3   sx    0 ,0(,"&-188 )8 &	8
  8 +8 8"y* m mr&   r   c                  b    e Zd ZdZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZd Zd	dZe	 	 	 	 	 	 d
d       Zy)r   a  Represents an onboarding prompt displayed in :class:`Onboarding`.

    .. versionadded:: 2.5

    Attributes
    ----------

    id: :class:`int`
        The id of the prompt.
    type: :class:`PromptType`
        The type of onboarding prompt.
    title: :class:`str`
        The prompt's title.
    options: List[:class:`PromptOption`]
        The list of options available in the prompt.
    single_select: :class:`bool`
        Whether the user is limited to selecting one option on this prompt.
    required: :class:`bool`
        Whether the user is required to answer this prompt.
    in_onboarding: :class:`bool`
        Whether this prompt is displayed in the initial onboarding flow.
    Nc                   |rt        |      n	t               | _        || _        t	        | j                  t               rt        t        | j                        | _        || _        || _        || _	        || _
        || _        y r   )r   r   r   type
isinstancer	   r   optionsr   single_selectrequiredin_onboarding)r#   rT   r   rV   rW   rX   rY   r   s           r$   r%   zOnboardingPrompt.__init__   sc     #%s2w*<*> $	dii% TYY7DI+2
#0&#0r&   c                V    d| j                    d| j                  d| j                   dS )Nz<OnboardingPrompt id=r(   z
 required=r)   )r   r   rX   r*   s    r$   r+   zOnboardingPrompt.__repr__   s*    &twwiwtzznJt}}o]^__r&   c           
         | j                   j                  | j                  | j                  | j                  | j
                  | j                  D cg c]  }|j                          c}| j                  d}|S c c}w )NrT   r   rW   rX   rY   rV   r   )	rT   valuer   rW   rX   rY   rV   r8   r   )r#   optionr7   s      r$   r8   zOnboardingPrompt.to_dict   sa    IIOOZZ!//!//7;||DV(D''*
 	 Es   A9c           	     z   |j                  dd      }t        t        |j                  d            }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  dg       D 	cg c]  }	t        j	                  |	|       }
}	 | ||||||
|	      S c c}	w )
Nr   r   rT   r   rW   rX   rY   rV   r\   )r   r	   r   r   rE   )r?   r@   rA   r   rT   r   rW   rX   rY   r^   rV   s              r$   rE   zOnboardingPrompt._from_dict   s     XXdA
DHHV$45!188J'1AE)UWAX
7=L##FE2
 
 EQYiv  AH  MO  P  	P	
s   
B8r   )rT   r   r   r4   rV   list[PromptOption]rW   boolrX   ra   rY   ra   r   rH   )rI   OnboardingPromptPayload)r@   rb   rA   r   rI   r   rK   rQ   r&   r$   r   r      s    > 11 1 $	1
 1 1 1 1,` P*P38P	P Pr&   r   c                      e Zd ZdZddZd ZddZe	 	 dd       Ze	e	e	e	e	d	 	 	 	 	 	 	 	 	 	 	 ddZ
dd		 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zdd		 	 	 ddZ	 	 ddZe	d		 	 	 ddZy)r   aj  Represents the onboarding flow for a guild.

    .. versionadded:: 2.5

    Attributes
    ----------

    prompts: List[:class:`OnboardingPrompt`]
        A list of prompts displayed in the onboarding flow.
    enabled: :class:`bool`
        Whether onboarding is enabled in the guild.
    mode: :class:`OnboardingMode`
        The current onboarding mode.
    c                4    || _         | j                  |       y r   )rA   _update)r#   r@   rA   s      r$   r%   zOnboarding.__init__   s    
Tr&   c           	     p    d| j                   d| j                   d| j                   d| j                   d	S )Nz<Onboarding guild=z	 enabled=z mode=z	 prompts=r)   )rA   enabledmodepromptsr*   s    r$   r+   zOnboarding.__repr__   s9    #DJJ>4<<.tyykYbcgcocobppqrrr&   c                P   |d   | _         |j                  dg       D cg c]"  }t        j                  || j                        $ c}| _        |d   D cg c]  }t        |       c}| _        |d   | _        t        t        |j                  d            | _        y c c}w c c}w )Nguild_idri   default_channel_idsrg   rh   )rk   r   r   rE   rA   ri   r   rl   rg   r	   r   rh   )r#   r@   promptcs       r$   re   zOnboarding._update   s    #'
#3 ((9b10
 ''

;0

 !!67/
CF/
  ")_$,^TXXf=M$N	0
/
s   'BB#c                    | j                   #| j                  D cg c]  }t        |       c}S | j                  D cg c]*  }| j                   j                  |      xs t        |      , c}S c c}w c c}w )zThe channels that members are opted into by default.

        If a channel is not found in the guild's cache,
        then it will be returned as an :class:`Object`.
        )rA   rl   r   r;   )r#   rB   s     r$   default_channelszOnboarding.default_channels   st     ::9=9Q9QR:F:&RR #66
 JJ"":.D&2DD
 	
 S
s
   A0/A5)ri   rp   rg   rh   reasonc                 K   i }|t         ur!|D cg c]  }|j                          c}|d<   |t         ur|D cg c]  }|j                   c}|d<   |t         ur||d<   |t         ur|j                  |d<   | j                  j
                  j                  j                  | j                  j                  ||       d{   }	| j                  |	       | S c c}w c c}w 7 !w)a  |coro|

        Edits this onboarding flow.

        You must have the :attr:`~Permissions.manage_guild` and :attr:`~Permissions.manage_roles` permissions in the
        guild to do this.

        Parameters
        ----------

        prompts: Optional[List[:class:`OnboardingPrompt`]]
            The new list of prompts for this flow.
        default_channels: Optional[List[:class:`Snowflake`]]
            The new default channels that users are opted into.
        enabled: Optional[:class:`bool`]
            Whether onboarding should be enabled. Setting this to ``True`` requires
            the guild to have ``COMMUNITY`` in :attr:`~Guild.features` and at
            least 7 ``default_channels``.
        mode: Optional[:class:`OnboardingMode`]
            The new onboarding mode.
        reason: Optional[:class:`str`]
            The reason for editing this onboarding flow. Shows up on the audit log.

        Returns
        -------
        :class:`Onboarding`
            The updated onboarding flow.

        Raises
        ------
        HTTPException
            Editing the onboarding flow failed somehow.
        Forbidden
            You don't have permissions to edit the onboarding flow.
        ri   rl   rg   rh   rq   N)	r   r8   r   r]   rA   _statehttpedit_onboardingre   )
r#   ri   rp   rg   rh   rq   fieldsrm   r5   news
             r$   editzOnboarding.edit
  s     Z "$'!@G Hf!1 HF97*GW,XGWZZ,XF()'! 'F9w!ZZF6NJJ%%**::JJMM6& ; 
 
 	S !I -Y
s'   C$CC$CA3C$ C""C$Nrs   c                  K   t        ||||||      }| j                  |gz   }	| j                  |	|       d{   S 7 w)a  |coro|

        Adds a new onboarding prompt.

        You must have the :attr:`~Permissions.manage_guild` and :attr:`~Permissions.manage_roles` permissions in the
        guild to do this.

        Parameters
        ----------
        type: :class:`PromptType`
            The type of onboarding prompt.
        title: :class:`str`
            The prompt's title.
        options: List[:class:`PromptOption`]
            The list of options available in the prompt.
        single_select: :class:`bool`
            Whether the user is limited to selecting one option on this prompt.
        required: :class:`bool`
            Whether the user is required to answer this prompt.
        in_onboarding: :class:`bool`
            Whether this prompt is displayed in the initial onboarding flow.
        reason: Optional[:class:`str`]
            The reason for adding this prompt. Shows up on the audit log.

        Returns
        -------
        :class:`Onboarding`
            The updated onboarding flow.

        Raises
        ------
        HTTPException
            Editing the onboarding flow failed somehow.
        Forbidden
            You don't have permissions to edit the onboarding flow.
        ri   rq   N)r   ri   ry   )
r#   rT   r   rV   rW   rX   rY   rq   rm   ri   s
             r$   
add_promptzOnboarding.add_promptJ  sK     ` "%-=
 ,,&)YYwvY>>>>s   7A >A c               d   K   | j                   |gz   }| j                  ||       d{   S 7 w)a  |coro|

        Append an onboarding prompt onto this flow.

        You must have the :attr:`~Permissions.manage_guild` and :attr:`~Permissions.manage_roles` permissions in the
        guild to do this.

        Parameters
        ----------
        prompt: :class:`OnboardingPrompt`
            The onboarding prompt to append.
        reason: Optional[:class:`str`]
            The reason for appending this prompt. Shows up on the audit log.

        Returns
        -------
        :class:`Onboarding`
            The updated onboarding flow.

        Raises
        ------
        HTTPException
            Editing the onboarding flow failed somehow.
        Forbidden
            You don't have permissions to edit the onboarding flow.
        r{   N)ri   ry   )r#   rm   rq   ri   s       r$   append_promptzOnboarding.append_prompt  s2     B ,,&)YYwvY>>>>s   '0.0c                0    t        | j                  |      S )a-  |coro|

        Get an onboarding prompt with the given ID.

        Parameters
        ----------
        id: :class:`int`
            The ID of the prompt to get.

        Returns
        -------
        :class:`OnboardingPrompt`
            The matching prompt, or None if it didn't exist.
        r:   )r   ri   )r#   r   s     r$   
get_promptzOnboarding.get_prompt  s    & 4<<B''r&   c                  K   | j                  |      }|st        d      | j                  dd }|j                  |       | j	                  ||       d{   S 7 w)a  |coro|

        Delete an onboarding prompt with the given ID.

        You must have the :attr:`~Permissions.manage_guild` and :attr:`~Permissions.manage_roles` permissions in the
        guild to do this.

        Parameters
        ----------
        id: :class:`int`
            The ID of the prompt to delete.
        reason: Optional[:class:`str`]
            The reason for deleting this prompt. Shows up on the audit log.

        Returns
        -------
        :class:`Onboarding`
            The updated onboarding flow.

        Raises
        ------
        ValueError
            No prompt with this ID exists.
        HTTPException
            Editing the onboarding flow failed somehow.
        Forbidden
            You don't have permissions to edit the onboarding flow.
        z'Prompt with the given ID was not found.Nr{   )r   
ValueErrorri   removery   )r#   r   rq   	to_deleteri   s        r$   delete_promptzOnboarding.delete_prompt  sX     F OOB'	FGG,,q/y!YYwvY>>>>s   AAAA)r@   OnboardingPayloadrA   r   )r@   r   )rI   z8list[TextChannel | ForumChannel | VoiceChannel | Object])ri   zlist[OnboardingPrompt] | Nonerp   rF   rg   zbool | Nonerh   zOnboardingMode | Nonerq   rG   rI   r   )rT   r   r   r4   rV   r`   rW   ra   rX   ra   rY   ra   rq   rG   )rm   r   rq   rG   )r   r   )r   r   rq   rG   )rL   rM   rN   rO   r%   r+   re   r   rp   r   ry   r|   r~   r   r   rQ   r&   r$   r   r      s   s
O 
	A
 
$ 293:&&-$> /> 1	>
 > $> > 
>R "4?4? 4? $	4?
 4? 4? 4? 4?t "	"? "? 	"?H((2 %	)?)? 	)?r&   r   N)%rO   
__future__r   typingr   r   enumsr   r   r	   partial_emojir
   utilsr   r   r   r   abcr   r5   r   r   r   r"   r   rA   r   objectr   types.onboardingr   r   r   rb   r   rJ   __all__rQ   r&   r$   <module>r      ss   0 # % 7 7 ' D D@@+AMERm RmjLP LP^K? K?r&   