mirror of
https://github.com/MelisaDev/melisa.git
synced 2024-11-11 19:07:28 +03:00
add fetch_guild method
This commit is contained in:
parent
49d2a5f899
commit
2ec9bd4ccf
1 changed files with 17 additions and 1 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue