diff options
| author | MhmCats <[email protected]> | 2021-06-02 07:39:08 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-02 02:39:08 -0400 |
| commit | 08470856614697e50419928ce6e24fb6291d95e9 (patch) | |
| tree | 9ece1810b8b1e4d8d32ab1f20319bbadcb046ed0 /discord/guild.py | |
| parent | Typehint audit_logs.py (diff) | |
| download | discord.py-08470856614697e50419928ce6e24fb6291d95e9.tar.xz discord.py-08470856614697e50419928ce6e24fb6291d95e9.zip | |
Add support for editing guild widgets
Diffstat (limited to 'discord/guild.py')
| -rw-r--r-- | discord/guild.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py index be223559..452edff2 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -2353,6 +2353,38 @@ class Guild(Hashable): data = await self._state.http.get_widget(self.id) 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: """|coro| |