Skip to content

Commit 5587fb6

Browse files
authored
Add reason support in welcome screen edits. (#171)
* Add support for adding reason in WelcomeScreen.edit * Add reason kwarg in http.edit_welcome_screen * Add reason in Guild.edit_welcome_screen * Update docstring Forgot to update the docstring whoops.
1 parent 311f19f commit 5587fb6

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

discord/guild.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,7 +3008,9 @@ async def edit_welcome_screen(self, **options):
30083008
The welcome channels. The order of the channels would be same as the passed list order.
30093009
enabled: Optional[:class:`bool`]
30103010
Whether the welcome screen should be displayed.
3011-
3011+
reason: Optional[:class:`str`]
3012+
The reason that shows up on audit log.
3013+
30123014
Raises
30133015
-------
30143016
@@ -3038,6 +3040,6 @@ async def edit_welcome_screen(self, **options):
30383040
options['welcome_channels'] = welcome_channels_data
30393041

30403042
if options:
3041-
new = await self._state.http.edit_welcome_screen(self.id, options)
3043+
new = await self._state.http.edit_welcome_screen(self.id, options, reason=options.get('reason'))
30423044
return WelcomeScreen(data=new, guild=self)
30433045

discord/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ def delete_channel_permissions(
14961496
def get_welcome_screen(self, guild_id: Snowflake) -> Response[welcome_screen.WelcomeScreen]:
14971497
return self.request(Route('GET', '/guilds/{guild_id}/welcome-screen', guild_id=guild_id))
14981498

1499-
def edit_welcome_screen(self, guild_id: Snowflake, payload: Any) -> Response[welcome_screen.WelcomeScreen]:
1499+
def edit_welcome_screen(self, guild_id: Snowflake, payload: Any, *, reason: Optional[str] = None) -> Response[welcome_screen.WelcomeScreen]:
15001500
keys = (
15011501
'description',
15021502
'welcome_channels',
@@ -1505,7 +1505,7 @@ def edit_welcome_screen(self, guild_id: Snowflake, payload: Any) -> Response[wel
15051505
payload = {
15061506
key: val for key, val in payload.items() if key in keys
15071507
}
1508-
return self.request(Route('PATCH', '/guilds/{guild_id}/welcome-screen', guild_id=guild_id), json=payload)
1508+
return self.request(Route('PATCH', '/guilds/{guild_id}/welcome-screen', guild_id=guild_id), json=payload, reason=reason)
15091509

15101510
# Voice management
15111511

discord/welcome_screen.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ async def edit(
149149
description: Optional[str] = ...,
150150
welcome_channels: Optional[List[WelcomeChannel]] = ...,
151151
enabled: Optional[bool] = ...,
152+
reason: Optional[str] = ...,
152153
) -> None:
153154
...
154155

@@ -188,7 +189,9 @@ async def edit(self, **options):
188189
The welcome channels. The order of the channels would be same as the passed list order.
189190
enabled: Optional[:class:`bool`]
190191
Whether the welcome screen should be displayed.
191-
192+
reason: Optional[:class:`str`]
193+
The reason that shows up on Audit log.
194+
192195
Raises
193196
-------
194197
@@ -213,7 +216,7 @@ async def edit(self, **options):
213216
options['welcome_channels'] = welcome_channels_data
214217

215218
if options:
216-
new = await self._guild._state.http.edit_welcome_screen(self._guild.id, options)
219+
new = await self._guild._state.http.edit_welcome_screen(self._guild.id, options, reason=options.get('reason'))
217220
self._update(new)
218221

219-
return self
222+
return self

0 commit comments

Comments
 (0)