mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 08:17:47 +00:00
Add missing parameters to certain methods
- slowmode_delay and reason in Message.create_thread - slowmode_delay in TextChannel.create_thread - reason in Guild.edit_widget
This commit is contained in:
parent
12d4de52a8
commit
e15415413b
@ -713,6 +713,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
type: Optional[ChannelType] = None,
|
||||
reason: Optional[str] = None,
|
||||
invitable: bool = True,
|
||||
slowmode_delay: Optional[int] = None,
|
||||
) -> Thread:
|
||||
"""|coro|
|
||||
|
||||
@ -743,6 +744,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
invitable: :class:`bool`
|
||||
Whether non-modertators can add users to the thread. Only applicable to private threads.
|
||||
Defaults to ``True``.
|
||||
slowmode_delay: Optional[:class:`int`]
|
||||
Specifies the slowmode rate limit for user in this channel, in seconds.
|
||||
The maximum value possible is `21600`. By default no slowmode rate limit
|
||||
if this is ``None``.
|
||||
|
||||
Raises
|
||||
-------
|
||||
@ -768,6 +773,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
type=type.value,
|
||||
reason=reason,
|
||||
invitable=invitable,
|
||||
rate_limit_per_user=slowmode_delay,
|
||||
)
|
||||
else:
|
||||
data = await self._state.http.start_thread_with_message(
|
||||
@ -776,6 +782,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
name=name,
|
||||
auto_archive_duration=auto_archive_duration or self.default_auto_archive_duration,
|
||||
reason=reason,
|
||||
rate_limit_per_user=slowmode_delay,
|
||||
)
|
||||
|
||||
return Thread(guild=self.guild, state=self._state, data=data)
|
||||
|
@ -3335,7 +3335,13 @@ class Guild(Hashable):
|
||||
|
||||
return Widget(state=self._state, data=data)
|
||||
|
||||
async def edit_widget(self, *, enabled: bool = MISSING, channel: Optional[Snowflake] = MISSING) -> None:
|
||||
async def edit_widget(
|
||||
self,
|
||||
*,
|
||||
enabled: bool = MISSING,
|
||||
channel: Optional[Snowflake] = MISSING,
|
||||
reason: Optional[str] = None,
|
||||
) -> None:
|
||||
"""|coro|
|
||||
|
||||
Edits the widget of the guild.
|
||||
@ -3351,6 +3357,8 @@ class Guild(Hashable):
|
||||
Whether to enable the widget for the guild.
|
||||
channel: Optional[:class:`~discord.abc.Snowflake`]
|
||||
The new widget channel. ``None`` removes the widget channel.
|
||||
reason: Optional[:class:`str`]
|
||||
The reason for editing this widget. Shows up on the audit log.
|
||||
|
||||
Raises
|
||||
-------
|
||||
@ -3365,7 +3373,7 @@ class Guild(Hashable):
|
||||
if enabled is not MISSING:
|
||||
payload['enabled'] = enabled
|
||||
|
||||
await self._state.http.edit_widget(self.id, payload=payload)
|
||||
await self._state.http.edit_widget(self.id, payload=payload, reason=reason)
|
||||
|
||||
async def chunk(self, *, cache: bool = True) -> Optional[List[Member]]:
|
||||
"""|coro|
|
||||
|
@ -923,11 +923,13 @@ class HTTPClient:
|
||||
*,
|
||||
name: str,
|
||||
auto_archive_duration: threads.ThreadArchiveDuration,
|
||||
rate_limit_per_user: Optional[int] = None,
|
||||
reason: Optional[str] = None,
|
||||
) -> Response[threads.Thread]:
|
||||
payload = {
|
||||
'name': name,
|
||||
'auto_archive_duration': auto_archive_duration,
|
||||
'rate_limit_per_user': rate_limit_per_user,
|
||||
}
|
||||
|
||||
route = Route(
|
||||
@ -943,6 +945,7 @@ class HTTPClient:
|
||||
auto_archive_duration: threads.ThreadArchiveDuration,
|
||||
type: threads.ThreadType,
|
||||
invitable: bool = True,
|
||||
rate_limit_per_user: Optional[int] = None,
|
||||
reason: Optional[str] = None,
|
||||
) -> Response[threads.Thread]:
|
||||
payload = {
|
||||
@ -950,6 +953,7 @@ class HTTPClient:
|
||||
'auto_archive_duration': auto_archive_duration,
|
||||
'type': type,
|
||||
'invitable': invitable,
|
||||
'rate_limit_per_user': rate_limit_per_user,
|
||||
}
|
||||
|
||||
route = Route('POST', '/channels/{channel_id}/threads', channel_id=channel_id)
|
||||
@ -1393,8 +1397,8 @@ class HTTPClient:
|
||||
def get_widget(self, guild_id: Snowflake) -> Response[widget.Widget]:
|
||||
return self.request(Route('GET', '/guilds/{guild_id}/widget.json', guild_id=guild_id))
|
||||
|
||||
def edit_widget(self, guild_id: Snowflake, payload) -> Response[widget.WidgetSettings]:
|
||||
return self.request(Route('PATCH', '/guilds/{guild_id}/widget', guild_id=guild_id), json=payload)
|
||||
def edit_widget(self, guild_id: Snowflake, payload, reason: Optional[str] = None) -> Response[widget.WidgetSettings]:
|
||||
return self.request(Route('PATCH', '/guilds/{guild_id}/widget', guild_id=guild_id), json=payload, reason=reason)
|
||||
|
||||
# Invite management
|
||||
|
||||
|
@ -1595,7 +1595,14 @@ class Message(Hashable):
|
||||
"""
|
||||
await self._state.http.clear_reactions(self.channel.id, self.id)
|
||||
|
||||
async def create_thread(self, *, name: str, auto_archive_duration: ThreadArchiveDuration = MISSING) -> Thread:
|
||||
async def create_thread(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
auto_archive_duration: ThreadArchiveDuration = MISSING,
|
||||
slowmode_delay: Optional[int] = None,
|
||||
reason: Optional[str] = None,
|
||||
) -> Thread:
|
||||
"""|coro|
|
||||
|
||||
Creates a public thread from this message.
|
||||
@ -1614,6 +1621,12 @@ class Message(Hashable):
|
||||
auto_archive_duration: :class:`int`
|
||||
The duration in minutes before a thread is automatically archived for inactivity.
|
||||
If not provided, the channel's default auto archive duration is used.
|
||||
slowmode_delay: Optional[:class:`int`]
|
||||
Specifies the slowmode rate limit for user in this channel, in seconds.
|
||||
The maximum value possible is `21600`. By default no slowmode rate limit
|
||||
if this is ``None``.
|
||||
reason: Optional[:class:`str`]
|
||||
The reason for creating a new thread. Shows up on the audit log.
|
||||
|
||||
Raises
|
||||
-------
|
||||
@ -1638,6 +1651,8 @@ class Message(Hashable):
|
||||
self.id,
|
||||
name=name,
|
||||
auto_archive_duration=auto_archive_duration or default_auto_archive_duration,
|
||||
rate_limit_per_user=slowmode_delay,
|
||||
reason=reason,
|
||||
)
|
||||
return Thread(guild=self.guild, state=self._state, data=data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user