mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Add mfa_level parameter to Guild.edit
This commit is contained in:
parent
7af70ac988
commit
2ca1a3a9a4
@ -1819,6 +1819,7 @@ class Guild(Hashable):
|
|||||||
invites_disabled: bool = MISSING,
|
invites_disabled: bool = MISSING,
|
||||||
widget_enabled: bool = MISSING,
|
widget_enabled: bool = MISSING,
|
||||||
widget_channel: Optional[Snowflake] = MISSING,
|
widget_channel: Optional[Snowflake] = MISSING,
|
||||||
|
mfa_level: MFALevel = MISSING,
|
||||||
) -> Guild:
|
) -> Guild:
|
||||||
r"""|coro|
|
r"""|coro|
|
||||||
|
|
||||||
@ -1852,7 +1853,7 @@ class Guild(Hashable):
|
|||||||
The ``discoverable`` and ``invites_disabled`` keyword parameters were added.
|
The ``discoverable`` and ``invites_disabled`` keyword parameters were added.
|
||||||
|
|
||||||
.. versionchanged:: 2.3
|
.. versionchanged:: 2.3
|
||||||
The ``widget_enabled`` and ``widget_channel`` keyword parameters were added.
|
The ``widget_enabled``, ``widget_channel``, and ``mfa_level`` keyword parameters were added.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@ -1923,6 +1924,9 @@ class Guild(Hashable):
|
|||||||
The new widget channel. ``None`` removes the widget channel.
|
The new widget channel. ``None`` removes the widget channel.
|
||||||
reason: Optional[:class:`str`]
|
reason: Optional[:class:`str`]
|
||||||
The reason for editing this guild. Shows up on the audit log.
|
The reason for editing this guild. Shows up on the audit log.
|
||||||
|
mfa_level: :class:`MFALevel`
|
||||||
|
The new guild’s Multi-Factor Authentication requirement level.
|
||||||
|
Note that you must be owner of the guild to do this.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
-------
|
-------
|
||||||
@ -1936,7 +1940,7 @@ class Guild(Hashable):
|
|||||||
guild and request an ownership transfer.
|
guild and request an ownership transfer.
|
||||||
TypeError
|
TypeError
|
||||||
The type passed to the ``default_notifications``, ``verification_level``,
|
The type passed to the ``default_notifications``, ``verification_level``,
|
||||||
``explicit_content_filter``, or ``system_channel_flags`` parameter was
|
``explicit_content_filter``, ``system_channel_flags``, or ``mfa_level`` parameter was
|
||||||
of the incorrect type.
|
of the incorrect type.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@ -2081,6 +2085,12 @@ class Guild(Hashable):
|
|||||||
if widget_payload:
|
if widget_payload:
|
||||||
await self._state.http.edit_widget(self.id, payload=widget_payload, reason=reason)
|
await self._state.http.edit_widget(self.id, payload=widget_payload, reason=reason)
|
||||||
|
|
||||||
|
if mfa_level is not MISSING:
|
||||||
|
if not isinstance(mfa_level, MFALevel):
|
||||||
|
raise TypeError(f'mfa_level must be of type MFALevel not {mfa_level.__class__.__name__}')
|
||||||
|
|
||||||
|
await http.edit_guild_mfa_level(self.id, mfa_level=mfa_level.value)
|
||||||
|
|
||||||
data = await http.edit_guild(self.id, reason=reason, **fields)
|
data = await http.edit_guild(self.id, reason=reason, **fields)
|
||||||
return Guild(data=data, state=self._state)
|
return Guild(data=data, state=self._state)
|
||||||
|
|
||||||
|
@ -1432,6 +1432,12 @@ class HTTPClient:
|
|||||||
|
|
||||||
return self.request(Route('PATCH', '/guilds/{guild_id}', guild_id=guild_id), json=payload, reason=reason)
|
return self.request(Route('PATCH', '/guilds/{guild_id}', guild_id=guild_id), json=payload, reason=reason)
|
||||||
|
|
||||||
|
def edit_guild_mfa_level(
|
||||||
|
self, guild_id: Snowflake, *, mfa_level: int, reason: Optional[str] = None
|
||||||
|
) -> Response[guild.GuildMFALevel]:
|
||||||
|
payload = {'level': mfa_level}
|
||||||
|
return self.request(Route('POST', '/guilds/{guild_id}/mfa', guild_id=guild_id), json=payload, reason=reason)
|
||||||
|
|
||||||
def get_template(self, code: str) -> Response[template.Template]:
|
def get_template(self, code: str) -> Response[template.Template]:
|
||||||
return self.request(Route('GET', '/guilds/templates/{code}', code=code))
|
return self.request(Route('GET', '/guilds/templates/{code}', code=code))
|
||||||
|
|
||||||
|
@ -161,6 +161,10 @@ class GuildPrune(TypedDict):
|
|||||||
pruned: Optional[int]
|
pruned: Optional[int]
|
||||||
|
|
||||||
|
|
||||||
|
class GuildMFALevel(TypedDict):
|
||||||
|
level: MFALevel
|
||||||
|
|
||||||
|
|
||||||
class ChannelPositionUpdate(TypedDict):
|
class ChannelPositionUpdate(TypedDict):
|
||||||
id: Snowflake
|
id: Snowflake
|
||||||
position: Optional[int]
|
position: Optional[int]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user