add fetch_guild method

This commit is contained in:
grey-cat-1908 2022-03-20 17:07:06 +03:00
parent 49d2a5f899
commit 2ec9bd4ccf

View file

@ -1,7 +1,7 @@
# Copyright MelisaDev 2022 - Present # Copyright MelisaDev 2022 - Present
# Full MIT License can be found in `LICENSE.txt` at the project root. # Full MIT License can be found in `LICENSE.txt` at the project root.
from .models import User from .models import User, Guild
from .models.app import Shard from .models.app import Shard
from .utils import Snowflake, APIModelBase from .utils import Snowflake, APIModelBase
from .utils.types import Coro from .utils.types import Coro
@ -141,3 +141,19 @@ class Client:
data = await self.http.get(f"users/{user_id}") data = await self.http.get(f"users/{user_id}")
return User.from_dict(data) return User.from_dict(data)
async def fetch_guild(self, guild_id: Union[Snowflake, str, int]):
"""
Fetch Guild from the Discord API (by id).
Parameters
----------
guild_id : :class:`Union[Snowflake, str, int]`
Id of guild to fetch
"""
# ToDo: Update cache if GUILD_CACHE enabled.
data = await self.http.get(f"guilds/{guild_id}")
return Guild.from_dict(data)