Pycord-Development / pycord

Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python
https://docs.pycord.dev
MIT License
2.74k stars 463 forks source link

Support GUILD_MEDIA channel type #2637

Open tibue99 opened 1 week ago

tibue99 commented 1 week ago

Summary

Messages in GUILD_MEDIA channels can lead to errors in current bots if they are not implemented.

What is the feature request for?

The core library

The Problem

When trying to fetch a media channel, an InvalidData error is thrown.

The Ideal Solution

Add GUILD_MEDIA as a channel type

The Current Solution

No response

Additional Context

No response

NeloBlivion commented 1 week ago

Media channels are hard to test because of their beta/exclusivity status, but for the most part they should operate the same as ForumChannel - do you have any examples/tracebacks we can look at? Or is it just the fact we never added the GUILD_MEDIA type (i.e. if you add media = 16 to enums.py -> ChannelType and adjust channel.py -> _guild_channel_factory to convert ChannelType.media to ForumChannel, does that fix your issues?)

tibue99 commented 6 days ago

It's hard to test for me, but here is my traceback. Adding the channel type might fix it.

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 442, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/cogs/level_system.py", line 257, in on_message
    parent_channel = await get_or_fetch(
                     ^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/utils.py", line 624, in get_or_fetch
    getter = await getattr(obj, f"fetch_{attr}")(id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 1878, in fetch_channel
    raise InvalidData(
discord.errors.InvalidData: Unknown channel type 16 for channel ID 1299532652516216956.
Lulalaby commented 6 days ago

Yeah that's the problem, I'm gonna fix it on master, please test it. Guild media channels have some extra properties but that shouldn't pose a problem.

tibue99 commented 6 days ago

To reproduce this, a media channel can ID be put into utils.get_or_fetch