Skip to content

Commit 708669b

Browse files
committed
Add PartialUser update_shield_mode_status
Add PartialUser update_shield_mode_status method
1 parent b929339 commit 708669b

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Master
1313
- Added ``igdb_ids`` argument to :func:`~twitchio.Client.fetch_games`
1414
- Added ``tags`` attribute to :class:`~twitchio.Stream`, :class:`~twitchio.ChannelInfo` and :class:`~twitchio.SearchUser`
1515
- Added :func:`~twitchio.PartialUser.fetch_shield_mode_status`
16+
- Added :func:`~twitchio.PartialUser.update_shield_mode_status`
1617

1718
- Bug fixes
1819
- Fix :func:`~twitchio.PartialUser.fetch_bits_leaderboard` not handling ``started_at`` and :class:`~twitchio.BitsLeaderboard` not correctly parsing

twitchio/http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,3 +1114,8 @@ async def get_shield_mode_status(self, token: str, broadcaster_id: str, moderato
11141114
return await self.request(
11151115
Route("GET", "moderation/shield_mode", query=q, token=token), paginate=False, full_body=False
11161116
)
1117+
1118+
async def put_shield_mode_status(self, token: str, broadcaster_id: str, moderator_id: str, is_active: bool):
1119+
q = [("broadcaster_id", broadcaster_id), ("moderator_id", moderator_id)]
1120+
body = {"is_active": is_active}
1121+
return await self.request(Route("PUT", "moderation/shield_mode", query=q, body=body, token=token))

twitchio/user.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,32 @@ async def fetch_shield_mode_status(self, token: str, moderator_id: int):
15261526

15271527
return ShieldStatus(self._http, data[0])
15281528

1529+
async def update_shield_mode_status(self, token: str, moderator_id: int, is_active: bool):
1530+
"""|coro|
1531+
1532+
Updates the user's Shield Mode activation status.
1533+
1534+
Parameters
1535+
-----------
1536+
token: :class:`str`
1537+
An oauth user token with the ``moderator:read:shield_mode`` or ``moderator:manage:shield_mode`` scope.
1538+
moderator_id: :class:`int`
1539+
The ID of the broadcaster or a user that is one of the broadcaster's moderators. This ID must match the user ID in the access token.
1540+
is_active: :class:`bool`
1541+
A Boolean value that determines whether to activate Shield Mode. Set to True to activate Shield Mode; otherwise, False to deactivate Shield Mode.
1542+
1543+
Returns
1544+
--------
1545+
:class:`twitchio.ShieldStatus`
1546+
"""
1547+
from .models import ShieldStatus
1548+
1549+
data = await self._http.put_shield_mode_status(
1550+
broadcaster_id=str(self.id), moderator_id=str(moderator_id), is_active=is_active, token=token
1551+
)
1552+
1553+
return ShieldStatus(self._http, data[0])
1554+
15291555

15301556
class BitLeaderboardUser(PartialUser):
15311557

0 commit comments

Comments
 (0)