Add support for editing guild widgets
This commit is contained in:
parent
369951fd80
commit
0847085661
@ -2354,6 +2354,38 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
return Widget(state=self._state, data=data)
|
return Widget(state=self._state, data=data)
|
||||||
|
|
||||||
|
async def edit_widget(self, *, enabled: bool = utils.MISSING, channel: Optional[abc.Snowflake] = utils.MISSING) -> None:
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
Edits the widget of the guild.
|
||||||
|
|
||||||
|
You must have the :attr:`~Permissions.manage_guild` permission to
|
||||||
|
use this
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
-----------
|
||||||
|
enabled: :class:`bool`
|
||||||
|
Whether to enable the widget for the guild.
|
||||||
|
channel: Optional[:class:`~discord.abc.Snowflake`]
|
||||||
|
The new widget channel. ``None`` removes the widget channel.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
-------
|
||||||
|
Forbidden
|
||||||
|
You do not have permission to edit the widget.
|
||||||
|
HTTPException
|
||||||
|
Editing the widget failed.
|
||||||
|
"""
|
||||||
|
payload = {}
|
||||||
|
if channel is not utils.MISSING:
|
||||||
|
payload['channel_id'] = None if channel is None else channel.id
|
||||||
|
if enabled is not utils.MISSING:
|
||||||
|
payload['enabled'] = enabled
|
||||||
|
|
||||||
|
await self._state.http.edit_widget(self.id, payload=payload)
|
||||||
|
|
||||||
async def chunk(self, *, cache: bool = True) -> None:
|
async def chunk(self, *, cache: bool = True) -> None:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
|
@ -972,6 +972,9 @@ class HTTPClient:
|
|||||||
def get_widget(self, guild_id):
|
def get_widget(self, guild_id):
|
||||||
return self.request(Route('GET', '/guilds/{guild_id}/widget.json', guild_id=guild_id))
|
return self.request(Route('GET', '/guilds/{guild_id}/widget.json', guild_id=guild_id))
|
||||||
|
|
||||||
|
def edit_widget(self, guild_id, payload):
|
||||||
|
return self.request(Route('PATCH', '/guilds/{guild_id}/widget', guild_id=guild_id), json=payload)
|
||||||
|
|
||||||
# Invite management
|
# Invite management
|
||||||
|
|
||||||
def create_invite(
|
def create_invite(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user