Browse Source

Remove duplicate spoiler properties

pull/10487/head
harumaki4649 3 weeks ago
parent
commit
d18f2fea78
  1. 30
      discord/channel.py
  2. 1
      tests/test_channel_flags.py

30
discord/channel.py

@ -434,20 +434,12 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
""":class:`bool`: Checks if the channel is NSFW."""
return self.nsfw
@property
def spoiler(self) -> bool:
""":class:`bool`: Whether members must opt in before viewing the channel's contents.
.. versionadded:: 2.8
"""
return self.flags.spoiler
def is_spoiler(self) -> bool:
""":class:`bool`: Checks if members must opt in before viewing the channel's contents.
.. versionadded:: 2.8
"""
return self.spoiler
return self.flags.spoiler
def is_news(self) -> bool:
""":class:`bool`: Checks if the channel is a news channel."""
@ -1169,20 +1161,12 @@ class VocalGuildChannel(discord.abc.Messageable, discord.abc.Connectable, discor
"""
return self.nsfw
@property
def spoiler(self) -> bool:
""":class:`bool`: Whether members must opt in before viewing the channel's contents.
.. versionadded:: 2.8
"""
return self.flags.spoiler
def is_spoiler(self) -> bool:
""":class:`bool`: Checks if members must opt in before viewing the channel's contents.
.. versionadded:: 2.8
"""
return self.spoiler
return self.flags.spoiler
@property
def flags(self) -> ChannelFlags:
@ -2679,20 +2663,12 @@ class ForumChannel(discord.abc.GuildChannel, Hashable):
""":class:`bool`: Checks if the forum is NSFW."""
return self.nsfw
@property
def spoiler(self) -> bool:
""":class:`bool`: Whether members must opt in before viewing the forum's contents.
.. versionadded:: 2.8
"""
return self.flags.spoiler
def is_spoiler(self) -> bool:
""":class:`bool`: Checks if members must opt in before viewing the forum's contents.
.. versionadded:: 2.8
"""
return self.spoiler
return self.flags.spoiler
def is_media(self) -> bool:
""":class:`bool`: Checks if the channel is a media channel.

1
tests/test_channel_flags.py

@ -67,5 +67,4 @@ async def test_text_channel_edit_sets_spoiler_flag():
assert state.http.options == {'flags': (1 << 4) | (1 << 21)}
assert edited is not None
assert edited.flags.spoiler is True
assert edited.spoiler is True
assert edited.is_spoiler() is True

Loading…
Cancel
Save