
    6g>                    j   d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
 ddlZddlmZ ddlmZmZ ddlmZmZmZmZmZ dd	lmZmZmZ d
Zer$ddl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+m,Z-  G d de      Z$ G d dee      Z. G d de.      Z& G d de.      Z( G d de(      Z* G d de(      Z,ddZ/y)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)LiteralTYPE_CHECKINGListOptionalTupleTypeUnionN   )Hashable)Asset
AssetMixin)cached_slot_propertysnowflake_timegetMISSING_get_as_snowflake)StickerTypeStickerFormatTypetry_enum)StickerPackStickerItemStickerStandardStickerGuildSticker)ConnectionState)User)Guildc                  F    e Zd ZdZdZd	dZd
dZedd       ZddZ	ddZ
y)r   a  Represents a sticker pack.

    .. versionadded:: 2.0

    .. container:: operations

        .. describe:: str(x)

            Returns the name of the sticker pack.

        .. describe:: x == y

           Checks if the sticker pack is equal to another sticker pack.

        .. describe:: x != y

           Checks if the sticker pack is not equal to another sticker pack.

    Attributes
    -----------
    name: :class:`str`
        The name of the sticker pack.
    description: :class:`str`
        The description of the sticker pack.
    id: :class:`int`
        The id of the sticker pack.
    stickers: List[:class:`StandardSticker`]
        The stickers of this sticker pack.
    sku_id: :class:`int`
        The SKU ID of the sticker pack.
    cover_sticker_id: Optional[:class:`int`]
         The ID of the sticker used for the cover of the sticker pack.
    cover_sticker: Optional[:class:`StandardSticker`]
        The sticker used for the cover of the sticker pack.
    )	_stateidstickersnamesku_idcover_sticker_idcover_stickerdescription_bannerc               4    || _         | j                  |       y Nr    
_from_dataselfstatedatas      e/var/www/python.lazyprojects.co.uk/rdoDiscordBot/venv/lib/python3.12/site-packages/discord/sticker.py__init__zStickerPack.__init__i       ',    c                p   t        |d         | _        |d   }|D cg c]  }t        | j                  |       c}| _        |d   | _        t        |d         | _        t        |d      | _        t        | j                  | j                        | _
        |d   | _        t        |d	      | _        y c c}w )
Nr!   r"   r/   r0   r#   r$   r%   )r!   r'   banner_asset_id)intr!   r   r    r"   r#   r$   r   r%   r   r&   r'   r(   )r.   r0   r"   stickers       r1   r,   zStickerPack._from_datam   s    4:
#px/ypxeldkkX_0`px/yf	tH~./@GY/Z8;DMMdNcNc8d $] 3&7>O&P 0zs   B3c                r    | j                   xr* t        j                  | j                  | j                         S )z5:class:`Asset`: The banner asset of the sticker pack.)r(   r   _from_sticker_bannerr    r.   s    r1   bannerzStickerPack.bannerx   s(     ||U : :4;; UUr4   c                V    d| j                    d| j                  d| j                  dS )Nz<StickerPack id= name=z description=>)r!   r#   r'   r<   s    r1   __repr__zStickerPack.__repr__}   s-    !$''&]4K[K[J^^_``r4   c                    | j                   S r*   r#   r<   s    r1   __str__zStickerPack.__str__       yyr4   N)r/   r   r0   StickerPackPayloadreturnNone)r0   rF   rG   rH   )rG   zOptional[Asset]rG   str)__name__
__module____qualname____doc__	__slots__r2   r,   propertyr=   rA   rD    r4   r1   r   r   8   s;    "H
I	Q V Var4   r   c                  :     e Zd ZU dZded<   ded<   d fdZ xZS )_StickerTagrQ   r8   r!   r   formatc                   K   | j                   t        j                  u rt        d      t        |           d{   S 7 w)a  |coro|

        Retrieves the content of this sticker as a :class:`bytes` object.

        .. note::

            Stickers that use the :attr:`StickerFormatType.lottie` format cannot be read.

        Raises
        ------
        HTTPException
            Downloading the asset failed.
        NotFound
            The asset was deleted.
        TypeError
            The sticker is a lottie type.

        Returns
        -------
        :class:`bytes`
            The content of the asset.
        z(Cannot read stickers of format "lottie".N)rT   r   lottie	TypeErrorsuperread)r.   	__class__s    r1   rY   z_StickerTag.read   s:     . ;;+222FGGW\^###s   9AAA)rG   bytes)rK   rL   rM   rO   __annotations__rY   __classcell__rZ   s   @r1   rS   rS      s    IG$ $r4   rS   c                  4    e Zd ZdZdZddZd	dZd	dZd
dZy)r   a  Represents a sticker item.

    .. versionadded:: 2.0

    .. container:: operations

        .. describe:: str(x)

            Returns the name of the sticker item.

        .. describe:: x == y

           Checks if the sticker item is equal to another sticker item.

        .. describe:: x != y

           Checks if the sticker item is not equal to another sticker item.

    Attributes
    -----------
    name: :class:`str`
        The sticker's name.
    id: :class:`int`
        The id of the sticker.
    format: :class:`StickerFormatType`
        The format for the sticker's image.
    url: :class:`str`
        The URL for the sticker's image.
    )r    r#   r!   rT   urlc               V   || _         |d   | _        t        |d         | _        t	        t
        |d         | _        | j                  t
        j                  u rd| j                   d| _        y t        j                   d| j                   d| j                  j                   | _        y )Nr#   r!   format_type&https://media.discordapp.net/stickers/.gif
/stickers/.)r    r#   r8   r!   r   r   rT   gifr`   r   BASEfile_extensionr-   s      r1   r2   zStickerItem.__init__   s    ',f	4:)12CT-EX)Y;;+///DTWWITRDH$zzl*TWWIQt{{?Y?Y>Z[DHr4   c                V    d| j                    d| j                  d| j                   dS )Nz<StickerItem id=r?   z format=r@   )r!   r#   rT   r<   s    r1   rA   zStickerItem.__repr__   s*    !$''&Xdkk]RSTTr4   c                    | j                   S r*   rC   r<   s    r1   rD   zStickerItem.__str__   rE   r4   c                   K   | j                   j                  j                  | j                         d{   }t	        |d         \  }} || j                   |      S 7 )w)a>  |coro|

        Attempts to retrieve the full sticker data of the sticker item.

        Raises
        --------
        HTTPException
            Retrieving the sticker failed.

        Returns
        --------
        Union[:class:`StandardSticker`, :class:`GuildSticker`]
            The retrieved sticker.
        Ntyper6   )r    httpget_stickerr!   _sticker_factory)r.   r0   cls_s       r1   fetchzStickerItem.fetch   sR      &*[[%5%5%A%A$''%JJ!$v,/Q400  Ks   3A!A*A!N)r/   r   r0   StickerItemPayloadrG   rH   rI   )rG   z-Union[Sticker, StandardSticker, GuildSticker])	rK   rL   rM   rN   rO   r2   rA   rD   rs   rQ   r4   r1   r   r      s$    < :I\U1r4   r   c                  F    e Zd ZdZdZd	dZd
dZddZddZe	dd       Z
y)r   a  Represents a sticker.

    .. versionadded:: 1.6

    .. container:: operations

        .. describe:: str(x)

            Returns the name of the sticker.

        .. describe:: x == y

           Checks if the sticker is equal to another sticker.

        .. describe:: x != y

           Checks if the sticker is not equal to another sticker.

    Attributes
    ----------
    name: :class:`str`
        The sticker's name.
    id: :class:`int`
        The id of the sticker.
    description: :class:`str`
        The description of the sticker.
    format: :class:`StickerFormatType`
        The format for the sticker's image.
    url: :class:`str`
        The URL for the sticker's image.
    )r    r!   r#   r'   rT   r`   c               4    || _         | j                  |       y r*   r+   r-   s      r1   r2   zSticker.__init__  r3   r4   c                \   t        |d         | _        |d   | _        |d   | _        t	        t
        |d         | _        | j                  t
        j                  u rd| j                   d| _        y t        j                   d| j                   d| j                  j                   | _        y )	Nr!   r#   r'   rb   rc   rd   re   rf   )r8   r!   r#   r'   r   r   rT   rg   r`   r   rh   ri   r.   r0   s     r1   r,   zSticker._from_data  s    4:f	 $] 3)12CT-EX)Y;;+///DTWWITRDH$zzl*TWWIQt{{?Y?Y>Z[DHr4   c                <    d| j                    d| j                  dS )Nz<Sticker id=r?   r@   )r!   r#   r<   s    r1   rA   zSticker.__repr__  s    dggYfTYYM;;r4   c                    | j                   S r*   rC   r<   s    r1   rD   zSticker.__str__  rE   r4   c                ,    t        | j                        S )zG:class:`datetime.datetime`: Returns the sticker's creation time in UTC.)r   r!   r<   s    r1   
created_atzSticker.created_at"  s     dgg&&r4   N)r/   r   r0   StickerPayloadrG   rH   )r0   r}   rG   rH   rI   )rG   zdatetime.datetime)rK   rL   rM   rN   rO   r2   r,   rA   rD   rP   r|   rQ   r4   r1   r   r      s9    @ II\< ' 'r4   r   c                  8     e Zd ZdZdZd fdZddZddZ xZS )	r   az  Represents a sticker that is found in a standard sticker pack.

    .. versionadded:: 2.0

    .. container:: operations

        .. describe:: str(x)

            Returns the name of the sticker.

        .. describe:: x == y

           Checks if the sticker is equal to another sticker.

        .. describe:: x != y

           Checks if the sticker is not equal to another sticker.

    Attributes
    ----------
    name: :class:`str`
        The sticker's name.
    id: :class:`int`
        The id of the sticker.
    description: :class:`str`
        The description of the sticker.
    pack_id: :class:`int`
        The id of the sticker's pack.
    format: :class:`StickerFormatType`
        The format for the sticker's image.
    tags: List[:class:`str`]
        A list of tags for the sticker.
    sort_value: :class:`int`
        The sticker's sort order within its pack.
    )
sort_valuepack_idrm   tagsc                *   t         |   |       |d   | _        t        |d         | _        t
        j                  | _        	 |d   j                  d      D cg c]  }|j                          c}| _
        y c c}w # t        $ r
 g | _
        Y y w xY w)Nr   r   r   ,)rX   r,   r   r8   r   r   standardrm   splitstripr   KeyError)r.   r0   tagrZ   s      r1   r,   zStandardSticker._from_dataO  s    4 #L1Y0!,!5!5		;?<;M;Mc;R#S;RCCIIK;R#SDI#S 	DI	s$   A? A:1A? :A? ?BBc                V    d| j                    d| j                  d| j                   dS )Nz<StandardSticker id=r?   z	 pack_id=r@   )r!   r#   r   r<   s    r1   rA   zStandardSticker.__repr__Z  s*    %dggYfTYYM4<<.XYZZr4   c                   K   | j                   j                  j                  | j                         d{   }t	        | j                   |      S 7 w)a  |coro|

        Retrieves the sticker pack that this sticker belongs to.

        .. versionchanged:: 2.5
            Now raises ``NotFound`` instead of ``InvalidData``.

        Raises
        --------
        NotFound
            The corresponding sticker pack was not found.
        HTTPException
            Retrieving the sticker pack failed.

        Returns
        --------
        :class:`StickerPack`
            The retrieved sticker pack.
        Nr6   )r    rn   get_sticker_packr   r   rx   s     r1   packzStandardSticker.pack]  s@     ( [[%%66t||DD488 Es   3AAA)r0   StandardStickerPayloadrG   rH   rI   )rG   r   )	rK   rL   rM   rN   rO   r,   rA   r   r]   r^   s   @r1   r   r   (  s     "H :I	[9r4   r   c                       e Zd ZdZdZd fdZddZ ed      dd       Ze	e	e	dd	 	 	 	 	 	 	 	 	 dd	Z
dd
ddZ xZS )r   a`  Represents a sticker that belongs to a guild.

    .. versionadded:: 2.0

    .. container:: operations

        .. describe:: str(x)

            Returns the name of the sticker.

        .. describe:: x == y

           Checks if the sticker is equal to another sticker.

        .. describe:: x != y

           Checks if the sticker is not equal to another sticker.

    Attributes
    ----------
    name: :class:`str`
        The sticker's name.
    id: :class:`int`
        The id of the sticker.
    description: :class:`str`
        The description of the sticker.
    format: :class:`StickerFormatType`
        The format for the sticker's image.
    available: :class:`bool`
        Whether this sticker is available for use.
    guild_id: :class:`int`
        The ID of the guild that this sticker is from.
    user: Optional[:class:`User`]
        The user that created this sticker. This can only be retrieved using :meth:`Guild.fetch_sticker` and
        having :attr:`~Permissions.manage_emojis_and_stickers`.
    emoji: :class:`str`
        The name of a unicode emoji that represents this sticker.
    )	availableguild_iduseremojirm   	_cs_guildc                    t         |   |       |j                  dd      | _        t	        |d         | _        |j                  d      }|r| j                  j                  |      nd | _        |d   | _	        t        j                  | _        y )Nr   Tr   r   r   )rX   r,   r   r   r8   r   r    
store_userr   r   r   guildrm   )r.   r0   r   rZ   s      r1   r,   zGuildSticker._from_data  ss    4 #xxT: j!12xxDHDKK$:$:4$@d	v,
!,!2!2	r4   c           	     p    d| j                   d| j                   d| j                   d| j                  d	S )Nz<GuildSticker name=z id=z
 guild_id=z user=r@   )r#   r!   r   r   r<   s    r1   rA   zGuildSticker.__repr__  s9    $TYYMdggYjW]^b^g^g]jjkllr4   r   c                L    | j                   j                  | j                        S )zOptional[:class:`Guild`]: The guild that this sticker is from.
        Could be ``None`` if the bot is not in the guild.

        .. versionadded:: 2.0
        )r    
_get_guildr   r<   s    r1   r   zGuildSticker.guild  s     {{%%dmm44r4   N)r#   r'   r   reasonc                 K   i }|t         ur||d<   |t         ur||d<   |t         ur-	 t        j                  |      }|j                  dd      }||d<   | j
                  j                  j                  | j                  | j                  ||       d{   }t        | j
                  |      S # t        $ r Y kw xY w7 *w)a  |coro|

        Edits a :class:`GuildSticker` for the guild.

        Parameters
        -----------
        name: :class:`str`
            The sticker's new name. Must be at least 2 characters.
        description: Optional[:class:`str`]
            The sticker's new description. Can be ``None``.
        emoji: :class:`str`
            The name of a unicode emoji that represents the sticker's expression.
        reason: :class:`str`
            The reason for editing this sticker. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You are not allowed to edit stickers.
        HTTPException
            An error occurred editing the sticker.

        Returns
        --------
        :class:`GuildSticker`
            The newly modified sticker.
        r#   r'    rr   r   Nr6   )r   unicodedatar#   replacerW   r    rn   modify_guild_stickerr   r!   r   )r.   r#   r'   r   r   payloadr0   s          r1   editzGuildSticker.edit  s     F w"GFOg%%0GM"0#((/ c3/#GFO*.++*:*:*O*OPTP]P]_c_f_fhoqw*x$x$++D99   %ys4   %C B/ AC B>C /	B;8C :B;;C )r   c                  K   | j                   j                  j                  | j                  | j                  |       d{    y7 w)a  |coro|

        Deletes the custom :class:`Sticker` from the guild.

        You must have :attr:`~Permissions.manage_emojis_and_stickers` to do this.

        Parameters
        -----------
        reason: Optional[:class:`str`]
            The reason for deleting this sticker. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You are not allowed to delete stickers.
        HTTPException
            An error occurred deleting the sticker.
        N)r    rn   delete_guild_stickerr   r!   )r.   r   s     r1   deletezGuildSticker.delete  s2     & kk33DMM477FSSSs   ?A	AA	)r0   GuildStickerPayloadrG   rH   rI   )rG   zOptional[Guild])
r#   rJ   r'   rJ   r   rJ   r   Optional[str]rG   r   )r   r   rG   rH   )rK   rL   rM   rN   rO   r,   rA   r   r   r   r   r   r]   r^   s   @r1   r   r   u  s    %N PI3m +&5 '5 " $6: 6: 	6:
 6: 6: 
6:p 7; T Tr4   r   c                    t        t        |       }|t        j                  k(  rt        |fS |t        j                  k(  rt
        |fS t        |fS r*   )r   r   r   r   r   r   r   )sticker_typevalues     r1   rp   rp     sJ    [,/E$$$%%	+##	#U""~r4   )r   zLiteral[1, 2]rG   zGTuple[Type[Union[StandardSticker, GuildSticker, Sticker]], StickerType])0rN   
__future__r   typingr   r   r   r   r   r	   r
   r   mixinsr   assetr   r   utilsr   r   r   r   r   enumsr   r   r   __all__datetimer/   r   r   r   r   r   types.stickerr   rF   r   rt   r   r}   r   r   r   r   rS   rp   rQ   r4   r1   <module>r      s   0 # M M M   $ X X ; ; & I( IX$(J $DB1+ B1J:'k :'zJ9g J9ZJT7 JTZr4   