Skip to content

Commit 54258f6

Browse files
committed
fix: adjust app emoji code based off testing
1 parent b798fbe commit 54258f6

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

interactions/client/smart_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def get_emoji(self, emoji_id: Optional["Snowflake_Type"]) -> Optional["CustomEmo
914914
"""
915915
return self.emoji_cache.get(to_optional_snowflake(emoji_id)) if self.emoji_cache is not None else None
916916

917-
def place_emoji_data(self, guild_id: "Snowflake_Type", data: discord_typings.EmojiData) -> "CustomEmoji":
917+
def place_emoji_data(self, guild_id: "Snowflake_Type | None", data: discord_typings.EmojiData) -> "CustomEmoji":
918918
"""
919919
Take json data representing an emoji, process it, and cache it. This cache is disabled by default, start your bot with `Client(enable_emoji_cache=True)` to enable it.
920920

interactions/models/discord/application.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from interactions.client.utils.attr_converters import optional
77
from interactions.client.utils.serializer import to_image_data
88
from interactions.models.discord.asset import Asset
9-
from interactions.models.discord.emoji import PartialEmoji
9+
from interactions.models.discord.emoji import CustomEmoji
1010
from interactions.models.discord.enums import ApplicationFlags
1111
from interactions.models.discord.file import UPLOADABLE_TYPE
1212
from interactions.models.discord.snowflake import Snowflake_Type, to_snowflake
@@ -92,34 +92,34 @@ def owner(self) -> "User":
9292
"""The user object for the owner of this application"""
9393
return self._client.cache.get_user(self.owner_id)
9494

95-
async def fetch_all_emoji(self) -> List[PartialEmoji]:
95+
async def fetch_all_emoji(self) -> List[CustomEmoji]:
9696
"""Fetch all emojis for this application"""
97-
response = await self._client.http.get_application_emojis(self.id)
98-
return [self._client.cache.place_emoji_data(None, emoji) for emoji in response]
97+
response = await self.client.http.get_application_emojis(self.id)
98+
return [self.client.cache.place_emoji_data(None, emoji) for emoji in response]
9999

100-
async def fetch_emoji(self, emoji_id: Snowflake_Type) -> PartialEmoji:
100+
async def fetch_emoji(self, emoji_id: Snowflake_Type) -> CustomEmoji:
101101
"""Fetch an emoji for this application"""
102-
response = await self._client.http.get_application_emoji(self.id, emoji_id)
103-
return await self._client.cache.place_emoji_data(None, response)
102+
response = await self.client.http.get_application_emoji(self.id, emoji_id)
103+
return self.client.cache.place_emoji_data(None, response)
104104

105-
async def create_emoji(self, name: str, imagefile: UPLOADABLE_TYPE) -> PartialEmoji:
105+
async def create_emoji(self, name: str, imagefile: UPLOADABLE_TYPE) -> CustomEmoji:
106106
"""Create an emoji for this application"""
107107
data_payload = {
108108
"name": name,
109109
"image": to_image_data(imagefile),
110110
"roles": MISSING,
111111
}
112112

113-
return self._client.cache.place_emoji_data(
114-
None, await self._client.http.create_application_emoji(data_payload, self.id)
113+
return self.client.cache.place_emoji_data(
114+
None, await self.client.http.create_application_emoji(data_payload, self.id)
115115
)
116116

117-
async def edit_emoji(self, emoji_id: Snowflake_Type, name: str) -> PartialEmoji:
117+
async def edit_emoji(self, emoji_id: Snowflake_Type, name: str) -> CustomEmoji:
118118
"""Edit an emoji for this application"""
119-
return await self._client.cache.place_emoji_data(
120-
None, self._client.http.edit_application_emoji(self.id, emoji_id, name)
119+
return self.client.cache.place_emoji_data(
120+
None, await self.client.http.edit_application_emoji(self.id, emoji_id, name)
121121
)
122122

123123
async def delete_emoji(self, emoji_id: Snowflake_Type) -> None:
124124
"""Delete an emoji for this application"""
125-
return await self._client.http.delete_application_emoji(self.id, emoji_id)
125+
await self.client.http.delete_application_emoji(self.id, emoji_id)

interactions/models/discord/emoji.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _process_dict(cls, data: Dict[str, Any], client: "Client") -> Dict[str, Any]
135135
return data
136136

137137
@classmethod
138-
def from_dict(cls, data: Dict[str, Any], client: "Client", guild_id: int) -> "CustomEmoji":
138+
def from_dict(cls, data: Dict[str, Any], client: "Client", guild_id: "Optional[Snowflake_Type]") -> "CustomEmoji":
139139
data = cls._process_dict(data, client)
140140
return cls(client=client, guild_id=guild_id, **cls._filter_kwargs(data, cls._get_init_keys()))
141141

@@ -216,6 +216,9 @@ async def delete(self, reason: Optional[str] = None) -> None:
216216
217217
"""
218218
if not self._guild_id:
219+
if reason:
220+
raise ValueError("Cannot specify reason for application emoji.")
221+
219222
await self.client.http.delete_application_emoji(self._client.app.id, self.id)
220223
else:
221224
await self._client.http.delete_guild_emoji(self._guild_id, self.id, reason=reason)

0 commit comments

Comments
 (0)