Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Add MediaChannel and fix ForumChannel flags #2641

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Paillat-dev
Copy link
Contributor

@Paillat-dev Paillat-dev commented Nov 8, 2024

Summary

Fix #2637
Fix #2640

Information

  • This PR fixes two issues.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Paillat-dev Paillat-dev requested a review from a team as a code owner November 8, 2024 21:37
@pullapprove4 pullapprove4 bot requested a review from VincentRPS November 8, 2024 21:37
@pullapprove4 pullapprove4 bot requested a review from Dorukyum November 8, 2024 21:37
@Paillat-dev Paillat-dev changed the title MediaChannel feat: ✨ Add MediaChannel and fix ForumChannel flags Nov 8, 2024
@Lulalaby Lulalaby requested review from Lulalaby and removed request for Dorukyum and VincentRPS November 8, 2024 21:56
Copy link
Member

@Lulalaby Lulalaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure but afaik I the channel class you also have a model for the base type which has type: literal channel type blah. Is that perhaps missing?

@Paillat-dev
Copy link
Contributor Author

I'm not entirely sure but afaik I the channel class you also have a model for the base type which has type: literal channel type blah. Is that perhaps missing?

type is present as a property in some channel classes but not all, for example it is not in TextChannel (which I found weird tbh) but is in others. I added it to ForumChannel and MediaChannel, even tough it works without because it is already implemented in _TextChannel as follows:

    @property
    def type(self) -> ChannelType:
        """The channel's Discord type."""
        return try_enum(ChannelType, self._type)

@Dorukyum
Copy link
Member

Dorukyum commented Nov 9, 2024

It's redundant if the classes inherit from _TextChannel.

@Paillat-dev
Copy link
Contributor Author

Undid it then

Lulalaby
Lulalaby previously approved these changes Nov 11, 2024
discord/abc.py Outdated
Comment on lines 419 to 420
if options.get("flags") and not isinstance(
options["flags"], int
): # it shouldn't be an int but just in case
options["flags"] = options["flags"].value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options["flags"] shouldn't ever be an integer

Suggested change
if options.get("flags") and not isinstance(
options["flags"], int
): # it shouldn't be an int but just in case
options["flags"] = options["flags"].value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where should it be made into an integer then ? I'm unsure. Because it needs to be sent as an integer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that it can't be an int at this point but yes it should be converted. See other conversions below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I should only remove the isinstance check here ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code with a try-except block to match the other options, haven't tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test tomorrow asap

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have time to test :/ but will do asap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work, I replaced it with contextlib.suppress but if you prefer try: except: pass I can revert the last commit.

discord/channel.py Show resolved Hide resolved
discord/channel.py Outdated Show resolved Hide resolved
discord/channel.py Outdated Show resolved Hide resolved
discord/channel.py Outdated Show resolved Hide resolved

@property
def hides_media_download_options(self) -> bool:
"""Whether media download options are be hidden in this media channel."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Whether media download options are be hidden in this media channel."""
"""Whether media download options are hidden in this media channel."""

what

default_reaction_emoji: Optional[:class:`discord.GuildEmoji` | :class:`int` | :class:`str`]
The default reaction emoji.
Can be a unicode emoji or a custom emoji in the forms:
:class:`GuildEmoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:class:`GuildEmoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
:class:`GuildEmoji`, snowflake ID, string representation (e.g., '<a:emoji_name:emoji_id>').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing channel types to channel.py Support GUILD_MEDIA channel type
4 participants