mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-08 04:38:42 +00:00
Make StreamIntegration.role a property rather than a strong reference
This commit is contained in:
parent
732c5384fd
commit
06743dd434
@ -25,9 +25,8 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Optional, TYPE_CHECKING, overload
|
from typing import Optional, TYPE_CHECKING, overload, Type, Tuple
|
||||||
from .utils import _get_as_snowflake, get, parse_time
|
from .utils import _get_as_snowflake, get, parse_time
|
||||||
from .role import Role
|
|
||||||
from .user import User
|
from .user import User
|
||||||
from .errors import InvalidArgument
|
from .errors import InvalidArgument
|
||||||
from .enums import try_enum, ExpireBehaviour
|
from .enums import try_enum, ExpireBehaviour
|
||||||
@ -48,6 +47,7 @@ if TYPE_CHECKING:
|
|||||||
IntegrationApplication as IntegrationApplicationPayload,
|
IntegrationApplication as IntegrationApplicationPayload,
|
||||||
)
|
)
|
||||||
from .guild import Guild
|
from .guild import Guild
|
||||||
|
from .role import Role
|
||||||
|
|
||||||
|
|
||||||
class IntegrationAccount:
|
class IntegrationAccount:
|
||||||
@ -161,8 +161,6 @@ class StreamIntegration(Integration):
|
|||||||
Whether the integration is currently enabled.
|
Whether the integration is currently enabled.
|
||||||
syncing: :class:`bool`
|
syncing: :class:`bool`
|
||||||
Where the integration is currently syncing.
|
Where the integration is currently syncing.
|
||||||
role: :class:`Role`
|
|
||||||
The role which the integration uses for subscribers.
|
|
||||||
enable_emoticons: Optional[:class:`bool`]
|
enable_emoticons: Optional[:class:`bool`]
|
||||||
Whether emoticons should be synced for this integration (currently twitch only).
|
Whether emoticons should be synced for this integration (currently twitch only).
|
||||||
expire_behaviour: :class:`ExpireBehaviour`
|
expire_behaviour: :class:`ExpireBehaviour`
|
||||||
@ -184,7 +182,6 @@ class StreamIntegration(Integration):
|
|||||||
'expire_grace_period',
|
'expire_grace_period',
|
||||||
'synced_at',
|
'synced_at',
|
||||||
'_role_id',
|
'_role_id',
|
||||||
'role',
|
|
||||||
'syncing',
|
'syncing',
|
||||||
'enable_emoticons',
|
'enable_emoticons',
|
||||||
'subscriber_count'
|
'subscriber_count'
|
||||||
@ -197,11 +194,15 @@ class StreamIntegration(Integration):
|
|||||||
self.expire_grace_period: int = data['expire_grace_period']
|
self.expire_grace_period: int = data['expire_grace_period']
|
||||||
self.synced_at: datetime.datetime = parse_time(data['synced_at'])
|
self.synced_at: datetime.datetime = parse_time(data['synced_at'])
|
||||||
self._role_id: int = int(data['role_id'])
|
self._role_id: int = int(data['role_id'])
|
||||||
self.role: Role = self.guild.get_role(self._role_id)
|
|
||||||
self.syncing: bool = data['syncing']
|
self.syncing: bool = data['syncing']
|
||||||
self.enable_emoticons: bool = data['enable_emoticons']
|
self.enable_emoticons: bool = data['enable_emoticons']
|
||||||
self.subscriber_count: int = data['subscriber_count']
|
self.subscriber_count: int = data['subscriber_count']
|
||||||
|
|
||||||
|
@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)
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
async def edit(
|
async def edit(
|
||||||
self,
|
self,
|
||||||
@ -358,7 +359,7 @@ class BotIntegration(Integration):
|
|||||||
self.application = IntegrationApplication(data=data['application'], state=self._state)
|
self.application = IntegrationApplication(data=data['application'], state=self._state)
|
||||||
|
|
||||||
|
|
||||||
def _integration_factory(value):
|
def _integration_factory(value: str) -> Tuple[Type[Integration], str]:
|
||||||
if value == 'discord':
|
if value == 'discord':
|
||||||
return BotIntegration, value
|
return BotIntegration, value
|
||||||
elif value in ('twitch', 'youtube'):
|
elif value in ('twitch', 'youtube'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user