Skip to content

Commit

Permalink
update all references to the Emoji class
Browse files Browse the repository at this point in the history
  • Loading branch information
NeloBlivion authored Sep 10, 2024
1 parent 0381a6e commit 4ccf9b1
Show file tree
Hide file tree
Showing 20 changed files with 101 additions and 101 deletions.
8 changes: 4 additions & 4 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ async def _edit(
except KeyError:
pass
else:
if isinstance(default_reaction_emoji, _EmojiTag): # Emoji, PartialEmoji
if isinstance(default_reaction_emoji, _EmojiTag): # GuildEmoji, PartialEmoji
default_reaction_emoji = default_reaction_emoji._to_partial()
elif isinstance(default_reaction_emoji, int):
default_reaction_emoji = PartialEmoji(
Expand All @@ -523,7 +523,7 @@ async def _edit(
default_reaction_emoji = PartialEmoji.from_str(default_reaction_emoji)
else:
raise InvalidArgument(
"default_reaction_emoji must be of type: Emoji | int | str"
"default_reaction_emoji must be of type: GuildEmoji | int | str"
)

options["default_reaction_emoji"] = (
Expand Down Expand Up @@ -1792,7 +1792,7 @@ def can_send(self, *objects) -> bool:
"Message": "send_messages",
"Embed": "embed_links",
"File": "attach_files",
"Emoji": "use_external_emojis",
"GuildEmoji": "use_external_emojis",
"GuildSticker": "use_external_stickers",
}
# Can't use channel = await self._get_channel() since its async
Expand All @@ -1817,7 +1817,7 @@ def can_send(self, *objects) -> bool:
mapping.get(type(obj).__name__) or mapping[obj.__name__]
)

if type(obj).__name__ == "Emoji":
if type(obj).__name__ == "GuildEmoji":
if (
obj._to_partial().is_unicode_emoji
or obj.guild_id == channel.guild.id
Expand Down
6 changes: 3 additions & 3 deletions discord/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import datetime

from . import abc
from .emoji import Emoji
from .emoji import GuildEmoji
from .guild import Guild
from .member import Member
from .role import Role
Expand Down Expand Up @@ -617,7 +617,7 @@ def target(
| User
| Role
| Invite
| Emoji
| GuildEmoji
| StageInstance
| GuildSticker
| Thread
Expand Down Expand Up @@ -689,7 +689,7 @@ def _convert_target_invite(self, target_id: int) -> Invite:
pass
return obj

def _convert_target_emoji(self, target_id: int) -> Emoji | Object:
def _convert_target_emoji(self, target_id: int) -> GuildEmoji | Object:
return self._state.get_emoji(target_id) or Object(id=target_id)

def _convert_target_message(self, target_id: int) -> Member | User | None:
Expand Down
12 changes: 6 additions & 6 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from . import utils
from .asset import Asset
from .emoji import Emoji
from .emoji import GuildEmoji
from .enums import (
ChannelType,
EmbeddedActivity,
Expand Down Expand Up @@ -143,7 +143,7 @@ def __init__(
self.emoji = PartialEmoji.from_str(emoji)
else:
raise TypeError(
"emoji must be a Emoji, PartialEmoji, or str and not"
"emoji must be a GuildEmoji, PartialEmoji, or str and not"
f" {emoji.__class__!r}"
)

Expand Down Expand Up @@ -1018,7 +1018,7 @@ class ForumChannel(_TextChannel):
The initial slowmode delay to set on newly created threads in this channel.
.. versionadded:: 2.3
default_reaction_emoji: Optional[:class:`str` | :class:`discord.Emoji`]
default_reaction_emoji: Optional[:class:`str` | :class:`discord.GuildEmoji`]
The default forum reaction emoji.
.. versionadded:: 2.5
Expand Down Expand Up @@ -1087,7 +1087,7 @@ async def edit(
default_auto_archive_duration: ThreadArchiveDuration = ...,
default_thread_slowmode_delay: int = ...,
default_sort_order: SortOrder = ...,
default_reaction_emoji: Emoji | int | str | None = ...,
default_reaction_emoji: GuildEmoji | int | str | None = ...,
available_tags: list[ForumTag] = ...,
require_tag: bool = ...,
overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ...,
Expand Down Expand Up @@ -1138,10 +1138,10 @@ async def edit(self, *, reason=None, **options):
The default sort order type to use to order posts in this channel.
.. versionadded:: 2.3
default_reaction_emoji: Optional[:class:`discord.Emoji` | :class:`int` | :class:`str`]
default_reaction_emoji: Optional[:class:`discord.GuildEmoji` | :class:`int` | :class:`str`]
The default reaction emoji.
Can be a unicode emoji or a custom emoji in the forms:
:class:`Emoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
:class:`GuildEmoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
.. versionadded:: 2.5
available_tags: List[:class:`ForumTag`]
Expand Down
8 changes: 4 additions & 4 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .utils import MISSING, get_slots

if TYPE_CHECKING:
from .emoji import Emoji
from .emoji import GuildEmoji, AppEmoji
from .types.components import ActionRow as ActionRowPayload
from .types.components import ButtonComponent as ButtonComponentPayload
from .types.components import Component as ComponentPayload
Expand Down Expand Up @@ -412,7 +412,7 @@ def __init__(
label: str,
value: str = MISSING,
description: str | None = None,
emoji: str | Emoji | PartialEmoji | None = None,
emoji: str | GuildEmoji | AppEmoji | PartialEmoji | None = None,
default: bool = False,
) -> None:
if len(label) > 100:
Expand Down Expand Up @@ -444,7 +444,7 @@ def __str__(self) -> str:
return base

@property
def emoji(self) -> str | Emoji | PartialEmoji | None:
def emoji(self) -> str | GuildEmoji | AppEmoji | PartialEmoji | None:
"""The emoji of the option, if available."""
return self._emoji

Expand All @@ -457,7 +457,7 @@ def emoji(self, value) -> None:
value = value._to_partial()
else:
raise TypeError(
"expected emoji to be str, Emoji, or PartialEmoji not"
"expected emoji to be str, GuildEmoji, AppEmoji, or PartialEmoji, not"
f" {value.__class__}"
)

Expand Down
8 changes: 4 additions & 4 deletions discord/ext/commands/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,8 @@ async def convert(self, ctx: Context, argument: str) -> discord.Guild:
return result


class EmojiConverter(IDConverter[discord.Emoji]):
"""Converts to a :class:`~discord.Emoji`.
class EmojiConverter(IDConverter[discord.GuildEmoji]):
"""Converts to a :class:`~discord.GuildEmoji`.
All lookups are done for the local guild first, if available. If that lookup
fails, then it checks the client's global cache.
Expand All @@ -821,7 +821,7 @@ class EmojiConverter(IDConverter[discord.Emoji]):
Raise :exc:`.EmojiNotFound` instead of generic :exc:`.BadArgument`
"""

async def convert(self, ctx: Context, argument: str) -> discord.Emoji:
async def convert(self, ctx: Context, argument: str) -> discord.GuildEmoji:
match = self._get_id_match(argument) or re.match(
r"<a?:\w{1,32}:([0-9]{15,20})>$", argument
)
Expand Down Expand Up @@ -1111,7 +1111,7 @@ def is_generic_type(tp: Any, *, _GenericAlias: type = _GenericAlias) -> bool:
discord.Colour: ColourConverter,
discord.VoiceChannel: VoiceChannelConverter,
discord.StageChannel: StageChannelConverter,
discord.Emoji: EmojiConverter,
discord.GuildEmoji: EmojiConverter,
discord.PartialEmoji: PartialEmojiConverter,
discord.CategoryChannel: CategoryChannelConverter,
discord.ForumChannel: ForumChannelConverter,
Expand Down
12 changes: 6 additions & 6 deletions discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PaginatorButton(discord.ui.Button):
label: :class:`str`
The label shown on the button.
Defaults to a capitalized version of ``button_type`` (e.g. "Next", "Prev", etc.)
emoji: Union[:class:`str`, :class:`discord.Emoji`, :class:`discord.PartialEmoji`]
emoji: Union[:class:`str`, :class:`discord.GuildEmoji`, :class:`discord.AppEmoji`, :class:`discord.PartialEmoji`]
The emoji shown on the button in front of the label.
disabled: :class:`bool`
Whether to initially show the button as disabled.
Expand All @@ -72,7 +72,7 @@ def __init__(
self,
button_type: str,
label: str = None,
emoji: str | discord.Emoji | discord.PartialEmoji = None,
emoji: str | discord.GuildEmoji | discord.AppEmoji | discord.PartialEmoji = None,
style: discord.ButtonStyle = discord.ButtonStyle.green,
disabled: bool = False,
custom_id: str = None,
Expand All @@ -89,7 +89,7 @@ def __init__(
)
self.button_type = button_type
self.label = label if label or emoji else button_type.capitalize()
self.emoji: str | discord.Emoji | discord.PartialEmoji = emoji
self.emoji: str | discord.GuildEmoji | discord.AppEmoji | discord.PartialEmoji = emoji
self.style = style
self.disabled = disabled
self.loop_label = self.label if not loop_label else loop_label
Expand Down Expand Up @@ -242,7 +242,7 @@ class PageGroup:
Also used as the SelectOption value.
description: Optional[:class:`str`]
The description shown on the corresponding PaginatorMenu dropdown option.
emoji: Union[:class:`str`, :class:`discord.Emoji`, :class:`discord.PartialEmoji`]
emoji: Union[:class:`str`, :class:`discord.GuildEmoji`, :class:`discord.AppEmoji`, :class:`discord.PartialEmoji`]
The emoji shown on the corresponding PaginatorMenu dropdown option.
default: Optional[:class:`bool`]
Whether the page group should be the default page group initially shown when the paginator response is sent.
Expand Down Expand Up @@ -278,7 +278,7 @@ def __init__(
pages: list[str] | list[Page] | list[list[discord.Embed] | discord.Embed],
label: str,
description: str | None = None,
emoji: str | discord.Emoji | discord.PartialEmoji = None,
emoji: str | discord.GuildEmoji | discord.AppEmoji | discord.PartialEmoji = None,
default: bool | None = None,
show_disabled: bool | None = None,
show_indicator: bool | None = None,
Expand All @@ -294,7 +294,7 @@ def __init__(
):
self.label = label
self.description: str | None = description
self.emoji: str | discord.Emoji | discord.PartialEmoji = emoji
self.emoji: str | discord.GuildEmoji | discord.AppEmoji | discord.PartialEmoji = emoji
self.pages: list[str] | list[list[discord.Embed] | discord.Embed] = pages
self.default: bool | None = default
self.show_disabled = show_disabled
Expand Down
2 changes: 1 addition & 1 deletion discord/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ def emojis_and_stickers(self):
This also corresponds to the following attributes and classes in terms of cache:
- :class:`Emoji`
- :class:`GuildEmoji`
- :class:`GuildSticker`
- :meth:`Client.get_emoji`
- :meth:`Client.get_sticker`
Expand Down
40 changes: 20 additions & 20 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from .channel import *
from .channel import _guild_channel_factory, _threaded_guild_channel_factory
from .colour import Colour
from .emoji import Emoji, PartialEmoji, _EmojiTag
from .emoji import GuildEmoji, PartialEmoji, _EmojiTag
from .enums import (
AuditLogAction,
AutoModEventType,
Expand Down Expand Up @@ -161,7 +161,7 @@ class Guild(Hashable):
----------
name: :class:`str`
The guild name.
emojis: Tuple[:class:`Emoji`, ...]
emojis: Tuple[:class:`GuildEmoji`, ...]
All emojis that the guild owns.
stickers: Tuple[:class:`GuildSticker`, ...]
All stickers that the guild owns.
Expand Down Expand Up @@ -476,7 +476,7 @@ def _from_data(self, guild: GuildPayload) -> None:
self._roles[role.id] = role

self.mfa_level: MFALevel = guild.get("mfa_level")
self.emojis: tuple[Emoji, ...] = tuple(
self.emojis: tuple[GuildEmoji, ...] = tuple(
map(lambda d: state.store_emoji(self, d), guild.get("emojis", []))
)
self.stickers: tuple[GuildSticker, ...] = tuple(
Expand Down Expand Up @@ -1404,7 +1404,7 @@ async def create_forum_channel(
slowmode_delay: int = MISSING,
nsfw: bool = MISSING,
overwrites: dict[Role | Member, PermissionOverwrite] = MISSING,
default_reaction_emoji: Emoji | int | str = MISSING,
default_reaction_emoji: GuildEmoji | int | str = MISSING,
) -> ForumChannel:
"""|coro|
Expand Down Expand Up @@ -1446,10 +1446,10 @@ async def create_forum_channel(
To mark the channel as NSFW or not.
reason: Optional[:class:`str`]
The reason for creating this channel. Shows up on the audit log.
default_reaction_emoji: Optional[:class:`Emoji` | :class:`int` | :class:`str`]
default_reaction_emoji: Optional[:class:`GuildEmoji` | :class:`int` | :class:`str`]
The default reaction emoji.
Can be a unicode emoji or a custom emoji in the forms:
:class:`Emoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
:class:`GuildEmoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
.. versionadded:: v2.5
Expand Down Expand Up @@ -1502,7 +1502,7 @@ async def create_forum_channel(
options["nsfw"] = nsfw

if default_reaction_emoji is not MISSING:
if isinstance(default_reaction_emoji, _EmojiTag): # Emoji, PartialEmoji
if isinstance(default_reaction_emoji, _EmojiTag): # GuildEmoji, PartialEmoji
default_reaction_emoji = default_reaction_emoji._to_partial()
elif isinstance(default_reaction_emoji, int):
default_reaction_emoji = PartialEmoji(
Expand All @@ -1512,7 +1512,7 @@ async def create_forum_channel(
default_reaction_emoji = PartialEmoji.from_str(default_reaction_emoji)
else:
raise InvalidArgument(
"default_reaction_emoji must be of type: Emoji | int | str"
"default_reaction_emoji must be of type: GuildEmoji | int | str"
)

options["default_reaction_emoji"] = (
Expand Down Expand Up @@ -2662,10 +2662,10 @@ async def delete_sticker(
"""
await self._state.http.delete_guild_sticker(self.id, sticker.id, reason)

async def fetch_emojis(self) -> list[Emoji]:
async def fetch_emojis(self) -> list[GuildEmoji]:
r"""|coro|
Retrieves all custom :class:`Emoji`\s from the guild.
Retrieves all custom :class:`GuildEmoji`\s from the guild.
.. note::
Expand All @@ -2678,16 +2678,16 @@ async def fetch_emojis(self) -> list[Emoji]:
Returns
--------
List[:class:`Emoji`]
List[:class:`GuildEmoji`]
The retrieved emojis.
"""
data = await self._state.http.get_all_custom_emojis(self.id)
return [Emoji(guild=self, state=self._state, data=d) for d in data]
return [GuildEmoji(guild=self, state=self._state, data=d) for d in data]

async def fetch_emoji(self, emoji_id: int, /) -> Emoji:
async def fetch_emoji(self, emoji_id: int, /) -> GuildEmoji:
"""|coro|
Retrieves a custom :class:`Emoji` from the guild.
Retrieves a custom :class:`GuildEmoji` from the guild.
.. note::
Expand All @@ -2701,7 +2701,7 @@ async def fetch_emoji(self, emoji_id: int, /) -> Emoji:
Returns
-------
:class:`Emoji`
:class:`GuildEmoji`
The retrieved emoji.
Raises
Expand All @@ -2712,7 +2712,7 @@ async def fetch_emoji(self, emoji_id: int, /) -> Emoji:
An error occurred fetching the emoji.
"""
data = await self._state.http.get_custom_emoji(self.id, emoji_id)
return Emoji(guild=self, state=self._state, data=data)
return GuildEmoji(guild=self, state=self._state, data=data)

async def create_custom_emoji(
self,
Expand All @@ -2721,10 +2721,10 @@ async def create_custom_emoji(
image: bytes,
roles: list[Role] = MISSING,
reason: str | None = None,
) -> Emoji:
) -> GuildEmoji:
r"""|coro|
Creates a custom :class:`Emoji` for the guild.
Creates a custom :class:`GuildEmoji` for the guild.
There is currently a limit of 50 static and animated emojis respectively per guild,
unless the guild has the ``MORE_EMOJI`` feature which extends the limit to 200.
Expand Down Expand Up @@ -2753,7 +2753,7 @@ async def create_custom_emoji(
Returns
--------
:class:`Emoji`
:class:`GuildEmoji`
The created emoji.
"""

Expand All @@ -2769,7 +2769,7 @@ async def delete_emoji(
) -> None:
"""|coro|
Deletes the custom :class:`Emoji` from the guild.
Deletes the custom :class:`GuildEmoji` from the guild.
You must have :attr:`~Permissions.manage_emojis` permission to
do this.
Expand Down
Loading

0 comments on commit 4ccf9b1

Please sign in to comment.