feat(guild): add list and get emoji

This commit is contained in:
ths_dev 2022-06-27 22:43:02 +03:00
parent 092d262f61
commit e1da3ee781
3 changed files with 105 additions and 1 deletions

2
.github/FUNDING.yml vendored
View file

@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://pay.cloudtips.ru/p/41f54886']
custom: ['https://pay.cloudtips.ru/p/41f54886', 'https://sobe.ru/na/makaroni']

View file

@ -24,6 +24,7 @@ from ...utils.types import APINullable
if TYPE_CHECKING:
from .channel import ChannelType, Channel
from .emoji import Emoji
class DefaultMessageNotificationLevel(IntEnum):
@ -619,6 +620,50 @@ class Guild(APIModelBase):
"""
await self._client.rest.remove_guild_ban(self.id, user_id, reason=reason)
async def emojis(
self
):
"""|coro|
Getting all emojis from guild
Raises
-------
HTTPException
The request to perform the action failed with other http exception.
ForbiddenError
You do not have proper permissions to do the actions required.
BadRequestError
You provided a wrong guild
"""
await self._client.rest.list_guild_emojis(self.id)
async def emoji(
self,
emoji_id: Union[Snowflake, str, int]
):
"""|coro|
Getting all emojis from guild
Parameters
----------
emoji_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
The ID of the emoji that we will get
Raises
-------
HTTPException
The request to perform the action failed with other http exception.
ForbiddenError
You do not have proper permissions to do the actions required.
BadRequestError
You provided a wrong guild and emoji
"""
await self._client.rest.get_guild_emoji(self.id, emoji_id)
@dataclass(repr=False)

View file

@ -666,6 +666,65 @@ class RESTApp:
headers={"X-Audit-Log-Reason": reason},
)
async def list_guild_emojis(
self,
guild_id: Union[Snowflake, str, int],
):
"""|coro|
[**REST API**] Getting all emojis from guild
Parameters
----------
guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
ID of the guild in which we will get the list emojis
Raises
-------
HTTPException
The request to perform the action failed with other http exception.
ForbiddenError
You do not have proper permissions to do the actions required.
BadRequestError
You provided a wrong guild
"""
await self._http.get(
f"/guilds/{guild_id}/emojis"
)
async def get_guild_emoji(
self,
guild_id: Union[Snowflake, str, int],
emoji_id: Union[Snowflake, str, int]
):
"""|coro|
[**REST API**] Getting all emojis from guild
Parameters
----------
guild_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
The ID of the guild in which we will receive emojis
emoji_id: Union[:class:`int`, :class:`str`, :class:`~.melisa.utils.snowflake.Snowflake`]
The ID of the emoji that we will get
Raises
-------
HTTPException
The request to perform the action failed with other http exception.
ForbiddenError
You do not have proper permissions to do the actions required.
BadRequestError
You provided a wrong guild and emoji
"""
await self._http.get(
f"/guilds/{guild_id}/emojis/{emoji_id}"
)
#TODO: add create and delete emoji
async def get_global_application_commands(
self,
application_id: Union[int, str, Snowflake],