
    cjhf                        d Z ddlmZ ddlmZ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 ddlmZ dZ G d d      Z G d d      Zy)ae  
The MIT License (MIT)

Copyright (c) 2015-2021 Rapptz
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overload   )	_EmojiTag)_get_as_snowflakeget)	Snowflake)Emoji)Guild)PartialEmoji)WelcomeScreen)WelcomeScreenChannel)r   r   c                  P    e Zd ZdZ	 	 	 	 	 	 ddZd ZddZe	 	 	 	 	 	 d	d       Zy)
r   a  Represents a welcome channel displayed on :class:`WelcomeScreen`

    .. versionadded:: 2.0

    Attributes
    ----------

    channel: :class:`abc.Snowflake`
        The channel that is being referenced.
    description: :class:`str`
        The description of the channel that is shown on the welcome screen.
    emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`]
        The emoji of the channel that is shown on welcome screen.
    c                .    || _         || _        || _        y Nchanneldescriptionemoji)selfr   r   r   s       I/var/www/html/venv/lib/python3.12/site-packages/discord/welcome_screen.py__init__zWelcomeScreenChannel.__init__A   s     &
    c                <    d| j                    d| j                   dS )NzWelcomeScreenChannel(channel=z description=))r   r   r   s    r   __repr__zWelcomeScreenChannel.__repr__K   s#    .t||nM$JZJZI[[\]]r   c                   | j                   j                  | j                  d d d}t        | j                  t
              r4| j                  j                  |d<   | j                  j                  |d<   |S | j                  |d<   d |d<   |S )N)
channel_idr   emoji_id
emoji_namer!   r"   )r   idr   
isinstancer   r   name)r   dict_s     r   to_dictzWelcomeScreenChannel.to_dictN   s}    ,,//++	.
 djj), $

E*"&**//E,  #'**E, $E*r   c                    t        |d      }|j                  |      }|j                  d      }t        |d      }|j                  d      }|rt        |j                  |      n|} | |||      S )Nr    r   r!   r"   )r#   r   )r   get_channelr	   emojis)	clsdataguildr    r   r   	_emoji_id_emoji_namer   s	            r   
_from_dictzWelcomeScreenChannel._from_dicta   sk     't\:
##J/hh}-%dJ7	hh|,3<ELLY/+75IIr   N)r   r
   r   strr   zEmoji | PartialEmoji | str)returnWelcomeScreenChannelPayload)r,   r3   r-   r   r2   r   )	__name__
__module____qualname____doc__r   r   r'   classmethodr0    r   r   r   r   1   sd      *	^& 
J.
J7<
J	
J 
Jr   r   c                      e Zd ZdZddZd ZddZedd       Zedd       Z	e
ddddd	 	 	 	 	 	 	 	 	 dd	       Ze
dd
       Zd Zy)r   a7  Represents the welcome screen of a guild.

    .. versionadded:: 2.0

    Attributes
    ----------

    description: :class:`str`
        The description text displayed on the welcome screen.
    welcome_channels: List[:class:`WelcomeScreenChannel`]
        A list of channels displayed on welcome screen.
    c                4    || _         | j                  |       y r   )_guild_update)r   r,   r-   s      r   r   zWelcomeScreen.__init__}   s    Tr   c                :    d| j                    d| j                   S )Nz<WelcomeScreen description=z welcome_channels=)r   welcome_channelsr   s    r   r   zWelcomeScreen.__repr__   s,     ,,--?@U@U?VX	
r   c                    |j                  d      | _        |j                  dg       D cg c]"  }t        j                  || j                        $ c}| _        y c c}w )Nr   r?   )r	   r   r   r0   r<   r?   )r   r,   r   s      r   r=   zWelcomeScreen._update   sR     $ 7  88$6;=
 !++GT[[A=
 =
s   'Ac                2    d| j                   j                  v S )z7Indicates whether the welcome screen is enabled or not.WELCOME_SCREEN_ENABLED)r<   featuresr   s    r   enabledzWelcomeScreen.enabled   s     (4;;+?+???r   c                    | j                   S )z)The guild this welcome screen belongs to.)r<   r   s    r   r-   zWelcomeScreen.guild   s     {{r   .)r   r?   rD   reasonc                  K   y wr   r9   )r   r   r?   rD   rF   s        r   editzWelcomeScreen.edit   s         c                   K   y wr   r9   r   s    r   rH   zWelcomeScreen.edit   s	     "%rI   c                  K   |j                  dg       }g }|D ]<  }t        |t              st        d      |j	                  |j                                > ||d<   |rn| j                  j                  j                  j                  | j                  j                  ||j                  d             d{   }| j                  |       | S 7 w)u  |coro|

        Edits the welcome screen.

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

        Parameters
        ----------

        description: Optional[:class:`str`]
            The new description of welcome screen.
        welcome_channels: Optional[List[:class:`WelcomeScreenChannel`]]
            The welcome channels. The order of the channels would be same as the passed list order.
        enabled: Optional[:class:`bool`]
            Whether the welcome screen should be displayed.
        reason: Optional[:class:`str`]
            The reason that shows up on Audit log.

        Raises
        ------

        HTTPException
            Editing the welcome screen failed somehow.
        Forbidden
            You don't have permissions to edit the welcome screen.
        NotFound
            This welcome screen does not exist.

        Example
        -------
        .. code-block:: python3

            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),
                ]
            )

        .. note::
            Welcome channels can only accept custom emojis if :attr:`~Guild.premium_tier` is level 2 or above.
        r?   zBwelcome_channels parameter must be a list of WelcomeScreenChannel.rF   )rF   N)r	   r$   r   	TypeErrorappendr'   r<   _statehttpedit_welcome_screenr#   r=   )r   optionsr?   welcome_channels_datar   news         r   rH   zWelcomeScreen.edit   s     d #;;'92> "' 	<Gg';<X  "(():;	< '<"#**//CCH0E D  C LLs   B5C7C8CN)r,   WelcomeScreenPayloadr-   r   )r,   rT   )r2   bool)r2   r   )
r   
str | Noner?   z!list[WelcomeScreenChannel] | NonerD   zbool | NonerF   rV   r2   None)r2   rW   )r4   r5   r6   r7   r   r   r=   propertyrD   r-   r   rH   r9   r   r   r   r   o   s    

 @ @    #&>A"    <	
   
  % %Er   r   N)r7   
__future__r   typingr   r   partial_emojir   utilsr   r	   abcr
   r   r   r-   r   r   types.welcome_screenr   rT   r   r3   __all__r9   r   r   <module>r`      sO   2 # * $ )+K;J ;J|{ {r   