Skip to content

Commit

Permalink
Revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDotCom committed Oct 17, 2022
1 parent e7a4c63 commit 2e9012b
Show file tree
Hide file tree
Showing 86 changed files with 431 additions and 862 deletions.
12 changes: 4 additions & 8 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,12 @@ class User(Snowflake, Protocol):

@property
def display_name(self) -> str:
""":class:`str`: Returns the user's display name.
"""
""":class:`str`: Returns the user's display name."""
raise NotImplementedError

@property
def mention(self) -> str:
""":class:`str`: Returns a string that allows you to mention the given user.
"""
""":class:`str`: Returns a string that allows you to mention the given user."""
raise NotImplementedError


Expand Down Expand Up @@ -525,8 +523,7 @@ def changed_roles(self) -> list[Role]:

@property
def mention(self) -> str:
""":class:`str`: The string that allows you to mention the channel.
"""
""":class:`str`: The string that allows you to mention the channel."""
return f"<#{self.id}>"

@property
Expand All @@ -539,8 +536,7 @@ def jump_url(self) -> str:

@property
def created_at(self) -> datetime:
""":class:`datetime.datetime`: Returns the channel's creation time in UTC.
"""
""":class:`datetime.datetime`: Returns the channel's creation time in UTC."""
return utils.snowflake_time(self.id)

def overwrites_for(self, obj: Role | User) -> PermissionOverwrite:
Expand Down
54 changes: 18 additions & 36 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ def to_dict(self) -> dict[str, Any]:

@property
def start(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user started doing this activity in UTC, if applicable.
"""
"""Optional[:class:`datetime.datetime`]: When the user started doing this activity in UTC, if applicable."""
try:
timestamp = self.timestamps["start"] / 1000
except KeyError:
Expand All @@ -290,8 +289,7 @@ def start(self) -> datetime.datetime | None:

@property
def end(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user will stop doing this activity in UTC, if applicable.
"""
"""Optional[:class:`datetime.datetime`]: When the user will stop doing this activity in UTC, if applicable."""
try:
timestamp = self.timestamps["end"] / 1000
except KeyError:
Expand All @@ -301,8 +299,7 @@ def end(self) -> datetime.datetime | None:

@property
def large_image_url(self) -> str | None:
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity if applicable.
"""
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity if applicable."""
if self.application_id is None:
return None

Expand All @@ -315,8 +312,7 @@ def large_image_url(self) -> str | None:

@property
def small_image_url(self) -> str | None:
"""Optional[:class:`str`]: Returns a URL pointing to the small image asset of this activity if applicable.
"""
"""Optional[:class:`str`]: Returns a URL pointing to the small image asset of this activity if applicable."""
if self.application_id is None:
return None

Expand All @@ -329,14 +325,12 @@ def small_image_url(self) -> str | None:

@property
def large_image_text(self) -> str | None:
"""Optional[:class:`str`]: Returns the large image asset hover text of this activity if applicable.
"""
"""Optional[:class:`str`]: Returns the large image asset hover text of this activity if applicable."""
return self.assets.get("large_text", None)

@property
def small_image_text(self) -> str | None:
"""Optional[:class:`str`]: Returns the small image asset hover text of this activity if applicable.
"""
"""Optional[:class:`str`]: Returns the small image asset hover text of this activity if applicable."""
return self.assets.get("small_text", None)


Expand Down Expand Up @@ -399,8 +393,7 @@ def type(self) -> ActivityType:

@property
def start(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user started playing this game in UTC, if applicable.
"""
"""Optional[:class:`datetime.datetime`]: When the user started playing this game in UTC, if applicable."""
if self._start:
return datetime.datetime.fromtimestamp(
self._start / 1000, tz=datetime.timezone.utc
Expand All @@ -409,8 +402,7 @@ def start(self) -> datetime.datetime | None:

@property
def end(self) -> datetime.datetime | None:
"""Optional[:class:`datetime.datetime`]: When the user will stop playing this game in UTC, if applicable.
"""
"""Optional[:class:`datetime.datetime`]: When the user will stop playing this game in UTC, if applicable."""
if self._end:
return datetime.datetime.fromtimestamp(
self._end / 1000, tz=datetime.timezone.utc
Expand Down Expand Up @@ -651,8 +643,7 @@ def to_dict(self) -> dict[str, Any]:

@property
def name(self) -> str:
""":class:`str`: The activity's name. This will always return "Spotify".
"""
""":class:`str`: The activity's name. This will always return "Spotify"."""
return "Spotify"

def __eq__(self, other: Any) -> bool:
Expand All @@ -677,14 +668,12 @@ def __repr__(self) -> str:

@property
def title(self) -> str:
""":class:`str`: The title of the song being played.
"""
""":class:`str`: The title of the song being played."""
return self._details

@property
def artists(self) -> list[str]:
"""List[:class:`str`]: The artists of the song being played.
"""
"""List[:class:`str`]: The artists of the song being played."""
return self._state.split("; ")

@property
Expand All @@ -698,14 +687,12 @@ def artist(self) -> str:

@property
def album(self) -> str:
""":class:`str`: The album that the song being played belongs to.
"""
""":class:`str`: The album that the song being played belongs to."""
return self._assets.get("large_text", "")

@property
def album_cover_url(self) -> str:
""":class:`str`: The album cover image URL from Spotify's CDN.
"""
""":class:`str`: The album cover image URL from Spotify's CDN."""
large_image = self._assets.get("large_image", "")
if large_image[:8] != "spotify:":
return ""
Expand All @@ -714,8 +701,7 @@ def album_cover_url(self) -> str:

@property
def track_id(self) -> str:
""":class:`str`: The track ID used by Spotify to identify this song.
"""
""":class:`str`: The track ID used by Spotify to identify this song."""
return self._sync_id

@property
Expand All @@ -728,30 +714,26 @@ def track_url(self) -> str:

@property
def start(self) -> datetime.datetime:
""":class:`datetime.datetime`: When the user started playing this song in UTC.
"""
""":class:`datetime.datetime`: When the user started playing this song in UTC."""
return datetime.datetime.fromtimestamp(
self._timestamps["start"] / 1000, tz=datetime.timezone.utc
)

@property
def end(self) -> datetime.datetime:
""":class:`datetime.datetime`: When the user will stop playing this song in UTC.
"""
""":class:`datetime.datetime`: When the user will stop playing this song in UTC."""
return datetime.datetime.fromtimestamp(
self._timestamps["end"] / 1000, tz=datetime.timezone.utc
)

@property
def duration(self) -> datetime.timedelta:
""":class:`datetime.timedelta`: The duration of the song being played.
"""
""":class:`datetime.timedelta`: The duration of the song being played."""
return self.end - self.start

@property
def party_id(self) -> str:
""":class:`str`: The party ID of the listening party.
"""
""":class:`str`: The party ID of the listening party."""
return self._party.get("id", "")


Expand Down
6 changes: 2 additions & 4 deletions discord/appinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ def __repr__(self) -> str:

@property
def icon(self) -> Asset | None:
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any.
"""
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any."""
if self._icon is None:
return None
return Asset._from_icon(self._state, self.id, self._icon, path="app")
Expand Down Expand Up @@ -254,8 +253,7 @@ def __repr__(self) -> str:

@property
def icon(self) -> Asset | None:
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any.
"""
"""Optional[:class:`.Asset`]: Retrieves the application's icon asset, if any."""
if self._icon is None:
return None
return Asset._from_icon(self._state, self.id, self._icon, path="app")
9 changes: 3 additions & 6 deletions discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,16 @@ def __hash__(self):

@property
def url(self) -> str:
""":class:`str`: Returns the underlying URL of the asset.
"""
""":class:`str`: Returns the underlying URL of the asset."""
return self._url

@property
def key(self) -> str:
""":class:`str`: Returns the identifying key of the asset.
"""
""":class:`str`: Returns the identifying key of the asset."""
return self._key

def is_animated(self) -> bool:
""":class:`bool`: Returns whether the asset is animated.
"""
""":class:`bool`: Returns whether the asset is animated."""
return self._animated

def replace(
Expand Down
15 changes: 5 additions & 10 deletions discord/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,7 @@ def __repr__(self) -> str:

@utils.cached_property
def created_at(self) -> datetime.datetime:
""":class:`datetime.datetime`: Returns the entry's creation time in UTC.
"""
""":class:`datetime.datetime`: Returns the entry's creation time in UTC."""
return utils.snowflake_time(self.id)

@utils.cached_property
Expand Down Expand Up @@ -558,28 +557,24 @@ def target(

@utils.cached_property
def category(self) -> enums.AuditLogActionCategory:
"""Optional[:class:`AuditLogActionCategory`]: The category of the action, if applicable.
"""
"""Optional[:class:`AuditLogActionCategory`]: The category of the action, if applicable."""
return self.action.category

@utils.cached_property
def changes(self) -> AuditLogChanges:
""":class:`AuditLogChanges`: The list of changes this entry has.
"""
""":class:`AuditLogChanges`: The list of changes this entry has."""
obj = AuditLogChanges(self, self._changes, state=self._state)
del self._changes
return obj

@utils.cached_property
def before(self) -> AuditLogDiff:
""":class:`AuditLogDiff`: The target's prior state.
"""
""":class:`AuditLogDiff`: The target's prior state."""
return self.changes.before

@utils.cached_property
def after(self) -> AuditLogDiff:
""":class:`AuditLogDiff`: The target's subsequent state.
"""
""":class:`AuditLogDiff`: The target's subsequent state."""
return self.changes.after

def _convert_target_guild(self, target_id: int) -> Guild:
Expand Down
6 changes: 2 additions & 4 deletions discord/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,12 @@ def __str__(self) -> str:

@cached_property
def guild(self) -> Guild | None:
"""Optional[:class:`Guild`]: The guild this rule belongs to.
"""
"""Optional[:class:`Guild`]: The guild this rule belongs to."""
return self._state._get_guild(self.guild_id)

@cached_property
def creator(self) -> Member | None:
"""Optional[:class:`Member`]: The member who created this rule.
"""
"""Optional[:class:`Member`]: The member who created this rule."""
if self.guild is None:
return None
return self.guild.get_member(self.creator_id)
Expand Down

0 comments on commit 2e9012b

Please sign in to comment.