Browse Source

Fix typing in emoji.py

pull/7494/head
Josh 3 years ago
committed by Rapptz
parent
commit
f5e087c5c3
  1. 14
      discord/emoji.py

14
discord/emoji.py

@ -116,8 +116,8 @@ class Emoji(_EmojiTag, AssetMixin):
def _from_data(self, emoji: EmojiPayload):
self.require_colons: bool = emoji.get('require_colons', False)
self.managed: bool = emoji.get('managed', False)
self.id: int = int(emoji['id']) # type: ignore
self.name: str = emoji['name'] # type: ignore
self.id: int = int(emoji['id']) # type: ignore - This won't be None for full emoji objects.
self.name: str = emoji['name'] # type: ignore - This won't be None for full emoji objects.
self.animated: bool = emoji.get('animated', False)
self.available: bool = emoji.get('available', True)
self._roles: SnowflakeList = SnowflakeList(map(int, emoji.get('roles', [])))
@ -175,7 +175,7 @@ class Emoji(_EmojiTag, AssetMixin):
return [role for role in guild.roles if self._roles.has(role.id)]
@property
def guild(self) -> Guild:
def guild(self) -> Optional[Guild]:
""":class:`Guild`: The guild this emoji belongs to."""
return self._state._get_guild(self.guild_id)
@ -184,7 +184,7 @@ class Emoji(_EmojiTag, AssetMixin):
.. versionadded:: 1.3
"""
if not self.available:
if not self.available or not self.guild or self.guild.unavailable:
return False
if not self._roles:
return True
@ -212,7 +212,7 @@ class Emoji(_EmojiTag, AssetMixin):
An error occurred deleting the emoji.
"""
await self._state.http.delete_custom_emoji(self.guild.id, self.id, reason=reason)
await self._state.http.delete_custom_emoji(self.guild_id, self.id, reason=reason)
async def edit(self, *, name: str = MISSING, roles: List[Snowflake] = MISSING, reason: Optional[str] = None) -> Emoji:
r"""|coro|
@ -253,5 +253,5 @@ class Emoji(_EmojiTag, AssetMixin):
if roles is not MISSING:
payload['roles'] = [role.id for role in roles]
data = await self._state.http.edit_custom_emoji(self.guild.id, self.id, payload=payload, reason=reason)
return Emoji(guild=self.guild, data=data, state=self._state)
data = await self._state.http.edit_custom_emoji(self.guild_id, self.id, payload=payload, reason=reason)
return Emoji(guild=self.guild, data=data, state=self._state) # type: ignore - if guild is None, the http request would have failed

Loading…
Cancel
Save