Skip to content

Commit 996c0f8

Browse files
committed
Typehint WelcomeScreen
1 parent b60ff11 commit 996c0f8

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

discord/guild.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2969,6 +2969,22 @@ async def welcome_screen(self):
29692969
"""
29702970
data = await self._state.http.get_welcome_screen(self.id)
29712971
return WelcomeScreen(data=data, guild=self)
2972+
2973+
2974+
@overload
2975+
async def edit_welcome_screen(
2976+
self,
2977+
*,
2978+
description: Optional[str] = ...,
2979+
welcome_channels: Optional[List[WelcomeChannel]] = ...,
2980+
enabled: Optional[bool] = ...,
2981+
) -> WelcomeScreen:
2982+
...
2983+
2984+
@overload
2985+
async def edit_welcome_screen(self) -> None:
2986+
...
2987+
29722988

29732989
async def edit_welcome_screen(self, **options):
29742990
"""|coro|
@@ -3012,7 +3028,7 @@ async def edit_welcome_screen(self, **options):
30123028

30133029
for channel in welcome_channels:
30143030
if not isinstance(channel, WelcomeScreenChannel):
3015-
raise InvalidArgument('welcome_channels parameter must be a list of WelcomeScreenChannel.')
3031+
raise TypeError('welcome_channels parameter must be a list of WelcomeScreenChannel.')
30163032

30173033
welcome_channels_data.append(channel.to_dict())
30183034

discord/welcome_screen.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,21 @@ def enabled(self) -> bool:
140140
def guild(self) -> Guild:
141141
""":class:`Guild`: The guild this welcome screen belongs to."""
142142
return self._guild
143+
144+
145+
@overload
146+
async def edit(
147+
self,
148+
*,
149+
description: Optional[str] = ...,
150+
welcome_channels: Optional[List[WelcomeChannel]] = ...,
151+
enabled: Optional[bool] = ...,
152+
) -> None:
153+
...
154+
155+
@overload
156+
async def edit(self) -> None:
157+
...
143158

144159
async def edit(self, **options):
145160
"""|coro|
@@ -184,19 +199,14 @@ async def edit(self, **options):
184199
NotFound
185200
This welcome screen does not exist.
186201
187-
Returns
188-
--------
189-
190-
:class:`WelcomeScreen`
191-
The updated welcome screen.
192202
"""
193203

194204
welcome_channels = options.get('welcome_channels', [])
195205
welcome_channels_data = []
196206

197207
for channel in welcome_channels:
198208
if not isinstance(channel, WelcomeScreenChannel):
199-
raise InvalidArgument('welcome_channels parameter must be a list of WelcomeScreenChannel.')
209+
raise TypeError('welcome_channels parameter must be a list of WelcomeScreenChannel.')
200210

201211
welcome_channels_data.append(channel.to_dict())
202212

0 commit comments

Comments
 (0)