Skip to content

Commit

Permalink
feat: support media channels (#1050)
Browse files Browse the repository at this point in the history
Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com>
  • Loading branch information
onerandomusername and shiftinv authored Feb 13, 2024
1 parent 0b1a047 commit 23d9106
Show file tree
Hide file tree
Showing 21 changed files with 1,425 additions and 771 deletions.
7 changes: 7 additions & 0 deletions changelog/1050.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Add support for media channels.
- Add :class:`MediaChannel`.
- Unless otherwise noted, media channels behave just like forum channels.
- Add :attr:`ChannelType.media`.
- Add :attr:`CategoryChannel.media_channels`, :attr:`Guild.media_channels`.
- Add :attr:`CategoryChannel.create_media_channel`, :attr:`Guild.create_media_channel`.
- Add :attr:`ChannelFlags.hide_media_download_options`.
1 change: 1 addition & 0 deletions disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class GuildChannel(ABC):
- :class:`.CategoryChannel`
- :class:`.StageChannel`
- :class:`.ForumChannel`
- :class:`.MediaChannel`
This ABC must also implement :class:`.abc.Snowflake`.
Expand Down
10 changes: 5 additions & 5 deletions disnake/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ def _transform_tag_id(
return None

# cyclic imports
from .channel import ForumChannel
from .channel import ThreadOnlyGuildChannel

tag: Optional[ForumTag] = None
tag_id = int(data)
thread = entry.target
# try thread parent first
if isinstance(thread, Thread) and isinstance(thread.parent, ForumChannel):
if isinstance(thread, Thread) and isinstance(thread.parent, ThreadOnlyGuildChannel):
tag = thread.parent.get_tag(tag_id)
else:
# if not found (possibly deleted thread), search all forum channels
for forum in entry.guild.forum_channels:
if tag := forum.get_tag(tag_id):
# if not found (possibly deleted thread), search all forum/media channels
for channel in entry.guild._channels.values():
if isinstance(channel, ThreadOnlyGuildChannel) and (tag := channel.get_tag(tag_id)):
break

return tag or Object(id=tag_id)
Expand Down
Loading

0 comments on commit 23d9106

Please sign in to comment.