
    it                        d Z ddlmZ ddlmZmZmZmZ ddlm	Z	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  G d d          Z 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)ListOptionalTYPE_CHECKINGUnion   )_get_as_snowflakegetMISSING)	_EmojiTag)WelcomeChannelWelcomeScreen)Self)r   WelcomeScreenChannel)	Snowflake)Guild)PartialEmoji)Emojic                  H    e Zd ZdZddddZddZedd            ZddZdS )r   a  Represents a :class:`WelcomeScreen` welcome channel.

    .. versionadded:: 2.0

    Attributes
    -----------
    channel: :class:`abc.Snowflake`
        The guild channel that is being referenced.
    description: :class:`str`
        The description shown of the channel.
    emoji: Optional[:class:`PartialEmoji`, :class:`Emoji`, :class:`str`]
        The emoji used beside the channel description.
    N)emojichannelr   descriptionstrr   )Optional[Union[PartialEmoji, Emoji, str]]returnNonec               0    || _         || _        || _        d S Nr   r   r   )selfr   r   r   s       W/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/welcome_screen.py__init__zWelcomeChannel.__init__A   s     &


    c                8    d| j         d| j        d| j        dS )Nz<WelcomeChannel channel=z description=z emoji=>r   r    s    r!   __repr__zWelcomeChannel.__repr__H   s,    q$,qqtGWqqbfblqqqqr#   dataWelcomeScreenChannelPayloadguildr   c                   t          |d                   }|                    |          }|d         }t          |d          }|d         }|rt          |j        |          }n|} | |||          S )N
channel_idr   emoji_id
emoji_name)idr   )intget_channelr	   r
   emojis)	clsr(   r*   r,   r   r   	_emoji_id_emoji_namer   s	            r!   
_from_dictzWelcomeChannel._from_dictK   s    l+,,
##J//=)%dJ77	<( 	 333EE  Es75IIIIr#   c                    | j         j        | j        d d d}t          | j        t
                    r| j        j        |d<   | j        j        |d<   n
| j        |d<   |S )N)r,   r   r-   r.   r-   r.   )r   r/   r   
isinstancer   r   name)r    rets     r!   to_dictzWelcomeChannel.to_dict^   sh    ,/+	,
 ,
 dj),, 	+"jmC
O $
C !%
C
r#   )r   r   r   r   r   r   r   r   r   r   )r(   r)   r*   r   r   r   )r   r)   )	__name__
__module____qualname____doc__r"   r'   classmethodr6   r;    r#   r!   r   r   2   s          ko     r r r r J J J [J$     r#   r   c                  V    e Zd ZdZddZdd	ZddZedd            Ze	e	e	ddddZ
dS )r   a$  Represents a :class:`Guild` welcome screen.

    .. versionadded:: 2.0

    Attributes
    -----------
    description: :class:`str`
        The description shown on the welcome screen.
    welcome_channels: List[:class:`WelcomeChannel`]
        The channels shown on the welcome screen.
    r(   WelcomeScreenPayloadr*   r   r   r   c               V    |j         | _         || _        |                     |           d S r   )_state_guild_store)r    r(   r*   s      r!   r"   zWelcomeScreen.__init__}   s*    lDr#   c                t     |d          _         |                    dg           } fd|D              _        d S )Nr   welcome_channelsc                R    g | ]#}t                               |j                   $S )r(   r*   )r   r6   rG   ).0wcr    s     r!   
<listcomp>z(WelcomeScreen._store.<locals>.<listcomp>   s;     7
 7
 7
FHN%%2T[%AA7
 7
 7
r#   )r   r
   rJ   )r    r(   rJ   s   `  r!   rH   zWelcomeScreen._store   sV     $] 388$6;;7
 7
 7
 7
L\7
 7
 7
r#   r   c                8    d| j         d| j        d| j         dS )Nz<WelcomeScreen description=z welcome_channels=z	 enabled=r%   )r   rJ   enabledr&   s    r!   r'   zWelcomeScreen.__repr__   sM     ET-=  E  ESWSh  E  Euy  vB  E  E  E  	Er#   boolc                    d| j         j        v S )z:class:`bool`: Whether the welcome screen is displayed.

        This is equivalent to checking if ``WELCOME_SCREEN_ENABLED``
        is present in :attr:`Guild.features`.
        WELCOME_SCREEN_ENABLED)rG   featuresr&   s    r!   rQ   zWelcomeScreen.enabled   s     (4;+???r#   N)r   rJ   rQ   reasonr   rJ   List[WelcomeChannel]rQ   rV   Optional[str]r   c                 K   i }|t           urWg }|D ]M}t          |t                    st          d          |                    |                                           N||d<   |t           ur||d<   |t           ur||d<    | j        j        j        | j	        j
        fd|i| d{V }|                     || j	                  S )u?  |coro|

        Edit the welcome screen.

        Welcome channels can only accept custom emojis if :attr:`Guild.premium_tier` is level 2 or above.

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

        Usage: ::

            rules_channel = guild.get_channel(12345678)
            announcements_channel = guild.get_channel(87654321)

            custom_emoji = utils.get(guild.emojis, name='loudspeaker')

            await welcome_screen.edit(
                description='This is a very cool community server!',
                welcome_channels=[
                    WelcomeChannel(channel=rules_channel, description='Read the rules!', emoji='👨‍🏫'),
                    WelcomeChannel(channel=announcements_channel, description='Watch out for announcements!', emoji=custom_emoji),
                ]
            )

        Parameters
        ------------
        description: Optional[:class:`str`]
            The welcome screen's description.
        welcome_channels: Optional[List[:class:`WelcomeChannel`]]
            The welcome channels, in their respective order.
        enabled: Optional[:class:`bool`]
            Whether the welcome screen should be displayed.
        reason: Optional[:class:`str`]
            The reason for editing the welcome screen. Shows up on the audit log.

        Raises
        -------
        HTTPException
            Editing the welcome screen failed.
        Forbidden
            You don't have permissions to edit the welcome screen.
        NotFound
            This welcome screen does not exist.
        z;welcome_channels parameter must be a list of WelcomeChannelrJ   r   rQ   rV   NrL   )r   r8   r   	TypeErrorappendr;   rF   httpedit_welcome_screenrG   r/   	__class__)	r    r   rJ   rQ   rV   fieldswelcome_channels_serialisedrN   r(   s	            r!   editzWelcomeScreen.edit   s      f 7***,'& A A!"n55 c#$abbb+222::<<@@@@)DF%&g%%$/F=!'!! 'F99T[%9$+.bbQWb[abbbbbbbb~~4t{~;;;r#   )r(   rD   r*   r   r   r   )r(   rD   r   r   r<   )r   rR   )
r   r   rJ   rW   rQ   rR   rV   rX   r   r   )r=   r>   r?   r@   r"   rH   r'   propertyrQ   r   ra   rB   r#   r!   r   r   p   s        
 
   

 
 
 
E E E E @ @ @ X@ #18 $D< D< D< D< D< D< D< D<r#   r   N)r@   
__future__r   typingr   r   r   r   utilsr	   r
   r   partial_emojir   __all__typing_extensionsr   types.welcome_screenr   rD   r   r)   abcr   r*   r   r   r   r   r   rB   r#   r!   <module>rk      sq   0 # " " " " " 7 7 7 7 7 7 7 7 7 7 7 7 2 2 2 2 2 2 2 2 2 2 $ $ $ $ $ $
  	&&&&&&        ++++++; ; ; ; ; ; ; ;|i< i< i< i< i< i< i< i< i< i<r#   