Skip to content

Commit 8379afb

Browse files
committed
♻️ As requested
1 parent 52cf072 commit 8379afb

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

discord/abc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from __future__ import annotations
2727

2828
import asyncio
29-
import contextlib
3029
import copy
3130
import time
3231
from typing import (
@@ -418,8 +417,10 @@ async def _edit(
418417
except KeyError:
419418
pass
420419

421-
with contextlib.suppress(KeyError):
420+
try:
422421
options["flags"] = options.pop("flags").value
422+
except KeyError:
423+
pass
423424

424425
try:
425426
options["available_tags"] = [

discord/channel.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from __future__ import annotations
2727

28-
import contextlib
2928
import datetime
3029
from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, TypeVar, overload
3130

@@ -1170,10 +1169,9 @@ async def edit(self, *, reason=None, **options):
11701169
HTTPException
11711170
Editing the channel failed.
11721171
"""
1173-
with contextlib.suppress(KeyError):
1174-
require_tag = options.pop("require_tag")
1172+
if "require_tag" in options:
11751173
options["flags"] = ChannelFlags._from_value(self.flags.value)
1176-
options["flags"].require_tag = require_tag
1174+
options["flags"].require_tag = options.pop("require_tag")
11771175

11781176
payload = await self._edit(options, reason=reason)
11791177
if payload is not None:
@@ -1432,8 +1430,11 @@ class MediaChannel(ForumChannel):
14321430
"""
14331431

14341432
@property
1435-
def hides_media_download_options(self) -> bool:
1436-
"""Whether media download options are hidden in this media channel."""
1433+
def media_download_options_hidden(self) -> bool:
1434+
"""Whether media download options are hidden in this media channel.
1435+
1436+
.. versionadded:: 2.7
1437+
"""
14371438
return self.flags.hide_media_download_options
14381439

14391440
@overload
@@ -1528,19 +1529,14 @@ async def edit(self, *, reason=None, **options):
15281529
HTTPException
15291530
Editing the channel failed.
15301531
"""
1531-
with contextlib.suppress(KeyError):
1532-
require_tag = options.pop("require_tag")
1533-
options["flags"] = options.get("flags") or ChannelFlags._from_value(
1534-
self.flags.value
1535-
)
1536-
options["flags"].require_tag = require_tag
15371532

1538-
with contextlib.suppress(KeyError):
1539-
hide_media_download_options = options.pop("hide_media_download_options")
1540-
options["flags"] = options.get("flags") or ChannelFlags._from_value(
1541-
self.flags.value
1533+
if "require_tag" in options or "hide_media_download_options" in options:
1534+
flags = ChannelFlags._from_value(self.flags.value)
1535+
flags.require_tag = options.pop("require_tag", flags.require_tag)
1536+
flags.hide_media_download_options = options.pop(
1537+
"hide_media_download_options", flags.hide_media_download_options
15421538
)
1543-
options["flags"].hide_media_download_options = hide_media_download_options
1539+
options["flags"] = flags
15441540

15451541
payload = await self._edit(options, reason=reason)
15461542
if payload is not None:

0 commit comments

Comments
 (0)