Fix code style issues with Black
This commit is contained in:
@@ -41,11 +41,12 @@ if TYPE_CHECKING:
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
'WidgetChannel',
|
||||
'WidgetMember',
|
||||
'Widget',
|
||||
"WidgetChannel",
|
||||
"WidgetMember",
|
||||
"Widget",
|
||||
)
|
||||
|
||||
|
||||
class WidgetChannel:
|
||||
"""Represents a "partial" widget channel.
|
||||
|
||||
@@ -76,7 +77,8 @@ class WidgetChannel:
|
||||
position: :class:`int`
|
||||
The channel's position
|
||||
"""
|
||||
__slots__ = ('id', 'name', 'position')
|
||||
|
||||
__slots__ = ("id", "name", "position")
|
||||
|
||||
def __init__(self, id: int, name: str, position: int) -> None:
|
||||
self.id: int = id
|
||||
@@ -87,18 +89,19 @@ class WidgetChannel:
|
||||
return self.name
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<WidgetChannel id={self.id} name={self.name!r} position={self.position!r}>'
|
||||
return f"<WidgetChannel id={self.id} name={self.name!r} position={self.position!r}>"
|
||||
|
||||
@property
|
||||
def mention(self) -> str:
|
||||
""":class:`str`: The string that allows you to mention the channel."""
|
||||
return f'<#{self.id}>'
|
||||
return f"<#{self.id}>"
|
||||
|
||||
@property
|
||||
def created_at(self) -> datetime.datetime:
|
||||
""":class:`datetime.datetime`: Returns the channel's creation time in UTC."""
|
||||
return snowflake_time(self.id)
|
||||
|
||||
|
||||
class WidgetMember(BaseUser):
|
||||
"""Represents a "partial" member of the widget's guild.
|
||||
|
||||
@@ -147,29 +150,37 @@ class WidgetMember(BaseUser):
|
||||
connected_channel: Optional[:class:`WidgetChannel`]
|
||||
Which channel the member is connected to.
|
||||
"""
|
||||
__slots__ = ('name', 'status', 'nick', 'avatar', 'discriminator',
|
||||
'id', 'bot', 'activity', 'deafened', 'suppress', 'muted',
|
||||
'connected_channel')
|
||||
|
||||
__slots__ = (
|
||||
"name",
|
||||
"status",
|
||||
"nick",
|
||||
"avatar",
|
||||
"discriminator",
|
||||
"id",
|
||||
"bot",
|
||||
"activity",
|
||||
"deafened",
|
||||
"suppress",
|
||||
"muted",
|
||||
"connected_channel",
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
activity: Optional[Union[BaseActivity, Spotify]]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
state: ConnectionState,
|
||||
data: WidgetMemberPayload,
|
||||
connected_channel: Optional[WidgetChannel] = None
|
||||
self, *, state: ConnectionState, data: WidgetMemberPayload, connected_channel: Optional[WidgetChannel] = None
|
||||
) -> None:
|
||||
super().__init__(state=state, data=data)
|
||||
self.nick: Optional[str] = data.get('nick')
|
||||
self.status: Status = try_enum(Status, data.get('status'))
|
||||
self.deafened: Optional[bool] = data.get('deaf', False) or data.get('self_deaf', False)
|
||||
self.muted: Optional[bool] = data.get('mute', False) or data.get('self_mute', False)
|
||||
self.suppress: Optional[bool] = data.get('suppress', False)
|
||||
self.nick: Optional[str] = data.get("nick")
|
||||
self.status: Status = try_enum(Status, data.get("status"))
|
||||
self.deafened: Optional[bool] = data.get("deaf", False) or data.get("self_deaf", False)
|
||||
self.muted: Optional[bool] = data.get("mute", False) or data.get("self_mute", False)
|
||||
self.suppress: Optional[bool] = data.get("suppress", False)
|
||||
|
||||
try:
|
||||
game = data['game']
|
||||
game = data["game"]
|
||||
except KeyError:
|
||||
activity = None
|
||||
else:
|
||||
@@ -190,6 +201,7 @@ class WidgetMember(BaseUser):
|
||||
""":class:`str`: Returns the member's display name."""
|
||||
return self.nick or self.name
|
||||
|
||||
|
||||
class Widget:
|
||||
"""Represents a :class:`Guild` widget.
|
||||
|
||||
@@ -227,27 +239,28 @@ class Widget:
|
||||
retrieved is capped.
|
||||
|
||||
"""
|
||||
__slots__ = ('_state', 'channels', '_invite', 'id', 'members', 'name')
|
||||
|
||||
__slots__ = ("_state", "channels", "_invite", "id", "members", "name")
|
||||
|
||||
def __init__(self, *, state: ConnectionState, data: WidgetPayload) -> None:
|
||||
self._state = state
|
||||
self._invite = data['instant_invite']
|
||||
self.name: str = data['name']
|
||||
self.id: int = int(data['id'])
|
||||
self._invite = data["instant_invite"]
|
||||
self.name: str = data["name"]
|
||||
self.id: int = int(data["id"])
|
||||
|
||||
self.channels: List[WidgetChannel] = []
|
||||
for channel in data.get('channels', []):
|
||||
_id = int(channel['id'])
|
||||
self.channels.append(WidgetChannel(id=_id, name=channel['name'], position=channel['position']))
|
||||
for channel in data.get("channels", []):
|
||||
_id = int(channel["id"])
|
||||
self.channels.append(WidgetChannel(id=_id, name=channel["name"], position=channel["position"]))
|
||||
|
||||
self.members: List[WidgetMember] = []
|
||||
channels = {channel.id: channel for channel in self.channels}
|
||||
for member in data.get('members', []):
|
||||
connected_channel = _get_as_snowflake(member, 'channel_id')
|
||||
for member in data.get("members", []):
|
||||
connected_channel = _get_as_snowflake(member, "channel_id")
|
||||
if connected_channel in channels:
|
||||
connected_channel = channels[connected_channel] # type: ignore
|
||||
elif connected_channel:
|
||||
connected_channel = WidgetChannel(id=connected_channel, name='', position=0)
|
||||
connected_channel = WidgetChannel(id=connected_channel, name="", position=0)
|
||||
|
||||
self.members.append(WidgetMember(state=self._state, data=member, connected_channel=connected_channel)) # type: ignore
|
||||
|
||||
@@ -260,7 +273,7 @@ class Widget:
|
||||
return False
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<Widget id={self.id} name={self.name!r} invite_url={self.invite_url!r}>'
|
||||
return f"<Widget id={self.id} name={self.name!r} invite_url={self.invite_url!r}>"
|
||||
|
||||
@property
|
||||
def created_at(self) -> datetime.datetime:
|
||||
|
||||
Reference in New Issue
Block a user