-
Notifications
You must be signed in to change notification settings - Fork 185
/
emojis.py
112 lines (86 loc) · 3.19 KB
/
emojis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from typing import TYPE_CHECKING, cast
import discord_typings
from interactions.models.internal.protocols import CanRequest
from ..route import Route
__all__ = ("EmojiRequests",)
if TYPE_CHECKING:
from interactions.models.discord.snowflake import Snowflake_Type
class EmojiRequests(CanRequest):
async def get_all_guild_emoji(self, guild_id: "Snowflake_Type") -> list[discord_typings.EmojiData]:
"""
Get all the emoji from a guild.
Args:
guild_id: The ID of the guild to query.
Returns:
List of emoji objects
"""
result = await self.request(Route("GET", "/guilds/{guild_id}/emojis", guild_id=guild_id))
return cast(list[discord_typings.EmojiData], result)
async def get_guild_emoji(
self, guild_id: "Snowflake_Type", emoji_id: "Snowflake_Type"
) -> discord_typings.EmojiData:
"""
Get a specific guild emoji object.
Args:
guild_id: The ID of the guild to query
emoji_id: The ID of the emoji to get
Returns:
PartialEmoji object
"""
result = await self.request(
Route("GET", "/guilds/{guild_id}/emojis/{emoji_id}", guild_id=guild_id, emoji_id=emoji_id)
)
return cast(discord_typings.EmojiData, result)
async def create_guild_emoji(
self, payload: dict, guild_id: "Snowflake_Type", reason: str | None = None
) -> discord_typings.EmojiData:
"""
Create a guild emoji.
Args:
payload: The emoji's data
guild_id: The ID of the guild
reason: The reason for this creation
Returns:
The created emoji object
"""
result = await self.request(
Route("POST", "/guilds/{guild_id}/emojis", guild_id=guild_id), payload=payload, reason=reason
)
return cast(discord_typings.EmojiData, result)
async def modify_guild_emoji(
self,
payload: dict,
guild_id: "Snowflake_Type",
emoji_id: "Snowflake_Type",
reason: str | None = None,
) -> discord_typings.EmojiData:
"""
Modify an existing guild emoji.
Args:
payload: The emoji's data
guild_id: The ID of the guild
emoji_id: The ID of the emoji to update
reason: The reason for this creation
Returns:
The updated emoji object
"""
result = await self.request(
Route("PATCH", "/guilds/{guild_id}/emojis/{emoji_id}", guild_id=guild_id, emoji_id=emoji_id),
payload=payload,
reason=reason,
)
return cast(discord_typings.EmojiData, result)
async def delete_guild_emoji(
self, guild_id: "Snowflake_Type", emoji_id: "Snowflake_Type", reason: str | None = None
) -> None:
"""
Delete a guild emoji.
Args:
guild_id: The ID of the guild
emoji_id: The ID of the emoji to update
reason: The reason for this deletion
"""
await self.request(
Route("DELETE", "/guilds/{guild_id}/emojis/{emoji_id}", guild_id=guild_id, emoji_id=emoji_id),
reason=reason,
)