mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 00:13:01 +00:00
Implement WelcomeScreen
This commit is contained in:
@@ -86,6 +86,7 @@ from .sticker import GuildSticker
|
||||
from .file import File
|
||||
from .audit_logs import AuditLogEntry
|
||||
from .object import OLDEST_OBJECT, Object
|
||||
from .welcome_screen import WelcomeScreen, WelcomeChannel
|
||||
|
||||
|
||||
__all__ = (
|
||||
@@ -3137,6 +3138,77 @@ class Guild(Hashable):
|
||||
|
||||
return roles
|
||||
|
||||
async def welcome_screen(self) -> WelcomeScreen:
|
||||
"""|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:: 2.0
|
||||
|
||||
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,
|
||||
*,
|
||||
description: str = MISSING,
|
||||
welcome_channels: List[WelcomeChannel] = MISSING,
|
||||
enabled: bool = MISSING,
|
||||
reason: Optional[str] = None,
|
||||
) -> WelcomeScreen:
|
||||
"""|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:: 2.0
|
||||
|
||||
Returns
|
||||
--------
|
||||
:class:`WelcomeScreen`
|
||||
The edited welcome screen.
|
||||
"""
|
||||
fields = {}
|
||||
|
||||
if welcome_channels is not MISSING:
|
||||
welcome_channels_serialised = []
|
||||
for wc in welcome_channels:
|
||||
if not isinstance(wc, WelcomeChannel):
|
||||
raise TypeError('welcome_channels parameter must be a list of WelcomeChannel')
|
||||
welcome_channels_serialised.append(wc.to_dict())
|
||||
fields['welcome_channels'] = welcome_channels_serialised
|
||||
|
||||
if description is not MISSING:
|
||||
fields['description'] = description
|
||||
|
||||
if enabled is not MISSING:
|
||||
fields['enabled'] = enabled
|
||||
|
||||
data = await self._state.http.edit_welcome_screen(self.id, reason=reason, **fields)
|
||||
return WelcomeScreen(data=data, guild=self)
|
||||
|
||||
async def kick(self, user: Snowflake, *, reason: Optional[str] = None) -> None:
|
||||
"""|coro|
|
||||
|
||||
|
Reference in New Issue
Block a user