mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-05 19:37:25 +00:00
Rework StreamIntegration.edit to not rely on state
This commit is contained in:
parent
62b024803a
commit
c6a69062a8
@ -25,8 +25,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import Optional, TYPE_CHECKING, overload, Type, Tuple
|
||||
from .utils import _get_as_snowflake, get, parse_time
|
||||
from typing import Any, Dict, Optional, TYPE_CHECKING, overload, Type, Tuple
|
||||
from .utils import _get_as_snowflake, parse_time, MISSING
|
||||
from .user import User
|
||||
from .errors import InvalidArgument
|
||||
from .enums import try_enum, ExpireBehaviour
|
||||
@ -204,23 +204,15 @@ class StreamIntegration(Integration):
|
||||
@property
|
||||
def role(self) -> Optional[Role]:
|
||||
"""Optional[:class:`Role`] The role which the integration uses for subscribers."""
|
||||
return self.guild.get_role(self._role_id)
|
||||
return self.guild.get_role(self._role_id) # type: ignore
|
||||
|
||||
@overload
|
||||
async def edit(
|
||||
self,
|
||||
*,
|
||||
expire_behaviour: Optional[ExpireBehaviour] = ...,
|
||||
expire_grace_period: Optional[int] = ...,
|
||||
enable_emoticons: Optional[bool] = ...,
|
||||
expire_behaviour: ExpireBehaviour = MISSING,
|
||||
expire_grace_period: int = MISSING,
|
||||
enable_emoticons: bool = MISSING,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def edit(self, **fields) -> None:
|
||||
...
|
||||
|
||||
async def edit(self, **fields) -> None:
|
||||
"""|coro|
|
||||
|
||||
Edits the integration.
|
||||
@ -246,34 +238,29 @@ class StreamIntegration(Integration):
|
||||
InvalidArgument
|
||||
``expire_behaviour`` did not receive a :class:`ExpireBehaviour`.
|
||||
"""
|
||||
try:
|
||||
expire_behaviour = fields['expire_behaviour']
|
||||
except KeyError:
|
||||
expire_behaviour = fields.get('expire_behavior', self.expire_behaviour)
|
||||
payload: Dict[str, Any] = {}
|
||||
if expire_behaviour is not MISSING:
|
||||
if not isinstance(expire_behaviour, ExpireBehaviour):
|
||||
raise InvalidArgument('expire_behaviour field must be of type ExpireBehaviour')
|
||||
|
||||
if not isinstance(expire_behaviour, ExpireBehaviour):
|
||||
raise InvalidArgument('expire_behaviour field must be of type ExpireBehaviour')
|
||||
payload['expire_behavior'] = expire_behaviour.value
|
||||
|
||||
expire_grace_period = fields.get('expire_grace_period', self.expire_grace_period)
|
||||
if expire_grace_period is not MISSING:
|
||||
payload['expire_grace_period'] = expire_grace_period
|
||||
|
||||
payload = {
|
||||
'expire_behavior': expire_behaviour.value,
|
||||
'expire_grace_period': expire_grace_period,
|
||||
}
|
||||
|
||||
try:
|
||||
enable_emoticons = fields['enable_emoticons']
|
||||
except KeyError:
|
||||
enable_emoticons = self.enable_emoticons
|
||||
else:
|
||||
if enable_emoticons is not MISSING:
|
||||
payload['enable_emoticons'] = enable_emoticons
|
||||
|
||||
await self._state.http.edit_integration(self.guild.id, self.id, **payload)
|
||||
|
||||
self.expire_behaviour = expire_behaviour
|
||||
self.expire_behavior = self.expire_behaviour
|
||||
self.expire_grace_period = expire_grace_period
|
||||
self.enable_emoticons = enable_emoticons
|
||||
if expire_behaviour is not MISSING:
|
||||
self.expire_behaviour = expire_behaviour
|
||||
|
||||
if enable_emoticons is not MISSING:
|
||||
self.enable_emoticons = enable_emoticons
|
||||
|
||||
if expire_grace_period is not MISSING:
|
||||
self.expire_grace_period = expire_grace_period
|
||||
|
||||
async def sync(self) -> None:
|
||||
"""|coro|
|
||||
|
Loading…
x
Reference in New Issue
Block a user