Skip to content

Commit 42c04d3

Browse files
committed
Move deco to http
1 parent 4aec990 commit 42c04d3

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

twitchio/http.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from .models.subscriptions import BroadcasterSubscription, BroadcasterSubscriptions
5959
from .models.videos import Video
6060
from .user import ActiveExtensions, PartialUser
61-
from .utils import Colour, _from_json, url_encode_datetime # type: ignore
61+
from .utils import Colour, _from_json, url_encode_datetime, handle_user_ids # type: ignore
6262

6363

6464
if TYPE_CHECKING:
@@ -586,16 +586,16 @@ async def converter(data: GameAnalyticsResponseData, *, raw: Any) -> GameAnalyti
586586
return iterator
587587

588588
### Bits ###
589-
589+
@handle_user_ids()
590590
async def get_bits_leaderboard(
591591
self,
592592
*,
593593
broadcaster_id: str | int,
594-
token_for: str,
594+
token_for: str | PartialUser,
595595
count: int = 10,
596596
period: Literal["day", "week", "month", "year", "all"] = "all",
597597
started_at: datetime.datetime | None = None,
598-
user_id: str | int | None = None,
598+
user_id: str | int | PartialUser | None = None,
599599
) -> BitsLeaderboardResponse:
600600
params: dict[str, str | int | datetime.datetime] = {
601601
"broadcaster_id": broadcaster_id,
@@ -605,10 +605,10 @@ async def get_bits_leaderboard(
605605

606606
if started_at is not None:
607607
params["started_at"] = url_encode_datetime(started_at)
608-
if user_id:
609-
params["user_id"] = user_id
608+
if user_id is not None:
609+
params["user_id"] = str(user_id)
610610

611-
route: Route = Route("GET", "bits/leaderboard", params=params, token_for=token_for)
611+
route: Route = Route("GET", "bits/leaderboard", params=params, token_for=str(token_for))
612612
return await self.request_json(route)
613613

614614
async def get_cheermotes(

twitchio/user.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from .exceptions import HTTPException
3131
from .models.ads import AdSchedule, CommercialStart, SnoozeAd
3232
from .models.raids import Raid
33-
from .utils import handle_user_ids, parse_timestamp
33+
from .utils import parse_timestamp
3434

3535

3636
if TYPE_CHECKING:
@@ -309,7 +309,6 @@ def fetch_game_analytics(
309309
max_results=max_results,
310310
)
311311

312-
@handle_user_ids(is_self=True)
313312
async def fetch_bits_leaderboard(
314313
self,
315314
token_for: str | PartialUser,

twitchio/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
741741
from .user import PartialUser
742742

743743
new_args = [
744-
(str(arg.id) if isinstance(arg, PartialUser) else arg)
744+
str(arg.id) if isinstance(arg, PartialUser) else arg
745745
for i, arg in enumerate(args)
746746
if not (is_self and i == 0)
747747
]

0 commit comments

Comments
 (0)