2828from typing import TYPE_CHECKING , List , Optional , Union , Tuple , Dict
2929
3030from .enums import BroadcasterTypeEnum , UserTypeEnum
31- from .errors import HTTPException , Unauthorized
31+ from .errors import HTTPException
3232from .rewards import CustomReward
3333from .utils import parse_timestamp
3434
3535
3636if TYPE_CHECKING :
3737 from .http import TwitchHTTP
3838 from .channel import Channel
39- from .models import BitsLeaderboard , Clip , ExtensionBuilder , Tag , FollowEvent , Prediction , CharityCampaign
39+ from .models import (
40+ BitsLeaderboard ,
41+ Clip ,
42+ ExtensionBuilder ,
43+ Tag ,
44+ FollowEvent ,
45+ Prediction ,
46+ CharityCampaign ,
47+ ChannelFollowerEvent ,
48+ ChannelFollowingEvent ,
49+ )
4050__all__ = (
4151 "PartialUser" ,
4252 "BitLeaderboardUser" ,
@@ -491,6 +501,10 @@ async def fetch_following(self, token: Optional[str] = None) -> List["FollowEven
491501
492502 Fetches a list of users that this user is following.
493503
504+ .. warning::
505+
506+ The endpoint this method uses has been deprecated by Twitch and is no longer available.
507+
494508 Parameters
495509 -----------
496510 token: Optional[:class:`str`]
@@ -510,6 +524,10 @@ async def fetch_followers(self, token: Optional[str] = None):
510524
511525 Fetches a list of users that are following this user.
512526
527+ .. warning::
528+
529+ The endpoint this method uses has been deprecated by Twitch and is no longer available.
530+
513531 Parameters
514532 -----------
515533 token: Optional[:class:`str`]
@@ -524,11 +542,65 @@ async def fetch_followers(self, token: Optional[str] = None):
524542 data = await self ._http .get_user_follows (token = token , to_id = str (self .id ))
525543 return [FollowEvent (self ._http , d , to = self ) for d in data ]
526544
545+ async def fetch_channel_followers (self , token : str , user_id : Optional [int ] = None ) -> List [ChannelFollowerEvent ]:
546+ """|coro|
547+
548+ Fetches a list of users that are following this broadcaster.
549+ Requires a user access token that includes the moderator:read:followers scope.
550+ The ID in the broadcaster_id query parameter must match the user ID in the access token or the user must be a moderator for the specified broadcaster.
551+
552+ Parameters
553+ -----------
554+ token: :class:`str`
555+ User access token that includes the ``moderator:read:followers`` scope for the channel.
556+ user_id: Optional[:class:`int`]
557+ Use this parameter to see whether the user follows this broadcaster.
558+
559+
560+ Returns
561+ --------
562+ List[:class:`twitchio.FollowEvent`]
563+ """
564+ from .models import ChannelFollowerEvent
565+
566+ data = await self ._http .get_channel_followers (token = token , broadcaster_id = str (self .id ), user_id = user_id )
567+ return [ChannelFollowerEvent (self ._http , d ) for d in data ]
568+
569+ async def fetch_channel_following (
570+ self , token : str , broadcaster_id : Optional [int ] = None
571+ ) -> List [ChannelFollowingEvent ]:
572+ """|coro|
573+
574+ Fetches a list of users that this user follows.
575+ Requires a user access token that includes the ``user:read:follows`` scope.
576+ The ID in the broadcaster_id query parameter must match the user ID in the access token or the user must be a moderator for the specified broadcaster.
577+
578+ Parameters
579+ -----------
580+ token: :class:`str`
581+ User access token that includes the moderator:read:followers scope for the channel.
582+ broadcaster_id: Optional[:class:`int`]
583+ Use this parameter to see whether the user follows this broadcaster.
584+
585+
586+ Returns
587+ --------
588+ List[:class:`twitchio.ChannelFollowingEvent`]
589+ """
590+ from .models import ChannelFollowingEvent
591+
592+ data = await self ._http .get_channel_followed (token = token , user_id = str (self .id ), broadcaster_id = broadcaster_id )
593+ return [ChannelFollowingEvent (self ._http , d ) for d in data ]
594+
527595 async def fetch_follow (self , to_user : "PartialUser" , token : Optional [str ] = None ):
528596 """|coro|
529597
530598 Check if a user follows another user or when they followed a user.
531599
600+ .. warning::
601+
602+ The endpoint this method uses has been deprecated by Twitch and is no longer available.
603+
532604 Parameters
533605 -----------
534606 to_user: :class:`PartialUser`
@@ -546,10 +618,50 @@ async def fetch_follow(self, to_user: "PartialUser", token: Optional[str] = None
546618 data = await self ._http .get_user_follows (token = token , from_id = str (self .id ), to_id = str (to_user .id ))
547619 return FollowEvent (self ._http , data [0 ]) if data else None
548620
621+ async def fetch_channel_follower_count (self , token : Optional [str ] = None ) -> int :
622+ """|coro|
623+
624+ Fetches the total number of users that are following this user.
625+
626+ Parameters
627+ -----------
628+ token: Optional[:class:`str`]
629+ An oauth token to use instead of the bots token
630+
631+ Returns
632+ --------
633+ :class:`int`
634+ """
635+
636+ data = await self ._http .get_channel_follower_count (token = token , broadcaster_id = str (self .id ))
637+ return data ["total" ]
638+
639+ async def fetch_channel_following_count (self , token : str ) -> int :
640+ """|coro|
641+
642+ Fetches the total number of users that the user is following.
643+
644+ Parameters
645+ -----------
646+ token: :class:`str`
647+ An oauth token to use instead of the bots token
648+
649+ Returns
650+ --------
651+ :class:`int`
652+ """
653+
654+ data = await self ._http .get_channel_followed_count (token = token , user_id = str (self .id ))
655+ return data ["total" ]
656+
549657 async def fetch_follower_count (self , token : Optional [str ] = None ) -> int :
550658 """|coro|
551659
552- Fetches a list of users that are following this user.
660+ Fetches the total number of users that are following this user.
661+
662+ .. warning::
663+
664+ The endpoint this method uses has been deprecated by Twitch and is no longer available.
553665
554666 Parameters
555667 -----------
@@ -569,6 +681,10 @@ async def fetch_following_count(self, token: Optional[str] = None) -> int:
569681
570682 Fetches a list of users that this user is following.
571683
684+ .. warning::
685+
686+ The endpoint this method uses has been deprecated by Twitch and is no longer available.
687+
572688 Parameters
573689 -----------
574690 token: Optional[:class:`str`]
0 commit comments