From efa0b4324e7a554a6d22d225ed0af680f639754d Mon Sep 17 00:00:00 2001 From: dolfies Date: Fri, 5 Nov 2021 22:14:22 -0400 Subject: [PATCH] Migrate a few more methods --- discord/guild.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/discord/guild.py b/discord/guild.py index 43b8de25d..558142699 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -2691,6 +2691,18 @@ class Guild(Hashable): self, before=before, after=after, limit=limit, oldest_first=oldest_first, user_id=user_id, action_type=action ) + async def ack(self): + """|coro| + + Marks every message in this guild as read. + + Raises + ------- + HTTPException + Acking failed. + """ + return await self._state.http.ack_guild(self.id) + async def widget(self) -> Widget: """|coro| @@ -2882,3 +2894,50 @@ class Guild(Hashable): region = str(preferred_region) if preferred_region else str(state.preferred_region) await ws.voice_state(self.id, channel_id, self_mute, self_deaf, self_video, region) + + async def mute(self, *, duration: Optional[int] = None) -> None: + """|coro| + + Mutes the guild. + + .. versionadded:: 1.9 + + Parameters + ----------- + duration: Optional[:class:`int`] + The duration (in hours) of the mute. Defaults to + ``None`` for an indefinite mute. + + Raises + ------- + HTTPException + Muting failed. + """ + + fields = { + 'muted': True + } + + if duration is not None: + mute_config = { + 'selected_time_window': duration * 3600, + 'end_time': (datetime.utcnow() + timedelta(hours=duration)).isoformat() + } + fields['mute_config'] = mute_config + + await self._state.http.edit_guild_settings(self.id, **fields) + + async def unmute(self) -> None: + """|coro| + + Unmutes the guild. + + .. versionadded:: 1.9 + + Raises + ------- + HTTPException + Unmuting failed. + """ + + await self._state.http.edit_guild_settings(self.id, muted=False) \ No newline at end of file