@@ -659,15 +659,15 @@ class Emote:
659
659
Represents an Emote.
660
660
661
661
.. note::
662
-
662
+
663
663
It seems twitch is sometimes returning duplicate information from the emotes endpoint.
664
664
To deduplicate your emotes, you can call ``set()`` on the list of emotes (or any other hashmap), which will remove the duplicates.
665
665
666
666
.. code-block:: python
667
667
668
668
my_list_of_emotes = await user.get_user_emotes(...)
669
669
deduplicated_emotes = set(my_list_of_emotes)
670
-
670
+
671
671
Attributes
672
672
-----------
673
673
id: :class:`str`
@@ -701,7 +701,18 @@ class Emote:
701
701
Whether this emote is available in dark theme background mode.
702
702
"""
703
703
704
- __slots__ = "id" , "set_id" , "owner_id" , "name" , "type" , "scales" , "format_static" , "format_animated" , "theme_light" , "theme_dark"
704
+ __slots__ = (
705
+ "id" ,
706
+ "set_id" ,
707
+ "owner_id" ,
708
+ "name" ,
709
+ "type" ,
710
+ "scales" ,
711
+ "format_static" ,
712
+ "format_animated" ,
713
+ "theme_light" ,
714
+ "theme_dark" ,
715
+ )
705
716
706
717
def __init__ (self , data : dict ) -> None :
707
718
self .id : str = data ["id" ]
@@ -714,7 +725,7 @@ def __init__(self, data: dict) -> None:
714
725
self .theme_light : bool = "light" in data ["theme_mode" ]
715
726
self .format_static : bool = "static" in data ["format" ]
716
727
self .format_animated : bool = "animated" in data ["format" ]
717
-
728
+
718
729
def url_for (self , format : Literal ["static" , "animated" ], theme : Literal ["dark" , "light" ], scale : str ) -> str :
719
730
"""
720
731
Returns a cdn url that can be used to download or serve the emote on a website.
@@ -729,26 +740,26 @@ def url_for(self, format: Literal["static", "animated"], theme: Literal["dark",
729
740
scale: :class:`str`
730
741
The scale of the emote. This should be formatted in this format: ``"1.0"``.
731
742
The scales available for this emote can be checked via :attr:`~.scales`.
732
-
743
+
733
744
Returns
734
745
--------
735
746
:class:`str`
736
747
"""
737
748
if scale not in self .scales :
738
749
raise ValueError (f"scale for this emote must be one of { ', ' .join (self .scales )} , not { scale } " )
739
-
750
+
740
751
if (theme == "dark" and not self .theme_dark ) or (theme == "light" and not self .theme_light ):
741
752
raise ValueError (f"theme { theme } is not an available value for this emote" )
742
753
743
754
if (format == "static" and not self .format_static ) or (format == "animated" and not self .format_animated ):
744
755
raise ValueError (f"format { format } is not an available value for this emote" )
745
-
756
+
746
757
return f"https://static-cdn.jtvnw.net/emoticons/v2/{ self .id } /{ format } /{ theme } /{ scale } "
747
-
758
+
748
759
def __repr__ (self ) -> str :
749
760
return f"<Emote id={ self .id } name={ self .name } >"
750
761
751
- def __hash__ (self ) -> int : # this exists so we can do set(list of emotes) to get rid of duplicates
762
+ def __hash__ (self ) -> int : # this exists so we can do set(list of emotes) to get rid of duplicates
752
763
return hash (self .id )
753
764
754
765
0 commit comments