implement WelcomeScreen

This commit is contained in:
NCPlayz
2021-02-24 22:25:32 +00:00
committed by Arthur Jovart
parent 6f5614373a
commit 27ed72369a
5 changed files with 273 additions and 0 deletions

View File

@@ -76,6 +76,7 @@ from .stage_instance import StageInstance
from .threads import Thread, ThreadMember
from .sticker import GuildSticker
from .file import File
from .welcome_screen import WelcomeScreen, WelcomeChannel
__all__ = (
@@ -2574,6 +2575,66 @@ class Guild(Hashable):
return roles
async def welcome_screen(self):
"""|coro|
Returns the guild's welcome screen.
The guild must have ``COMMUNITY`` in :attr:`~Guild.features`.
You must have the :attr:`~Permissions.manage_guild` permission to use
this as well.
.. versionadded:: 1.7
Raises
-------
Forbidden
You do not have the proper permissions to get this.
HTTPException
Retrieving the welcome screen failed.
Returns
--------
:class:`WelcomeScreen`
The welcome screen.
"""
data = await self._state.http.get_welcome_screen(self.id)
return WelcomeScreen(data=data, guild=self)
async def edit_welcome_screen(self, **kwargs):
"""|coro|
A shorthand method of :attr:`WelcomeScreen.edit` without needing
to fetch the welcome screen beforehand.
The guild must have ``COMMUNITY`` in :attr:`~Guild.features`.
You must have the :attr:`~Permissions.manage_guild` permission to use
this as well.
.. versionadded:: 1.7
Returns
--------
:class:`WelcomeScreen`
The edited welcome screen.
"""
try:
welcome_channels = kwargs['welcome_channels']
except KeyError:
pass
else:
welcome_channels_serialised = []
for wc in welcome_channels:
if not isinstance(wc, WelcomeChannel):
raise InvalidArgument('welcome_channels parameter must be a list of WelcomeChannel')
welcome_channels_serialised.append(wc.to_dict())
if kwargs:
data = await self._state.http.edit_welcome_screen(self.id, kwargs)
return WelcomeScreen(data=data, guild=self)
async def kick(self, user: Snowflake, *, reason: Optional[str] = None) -> None:
"""|coro|