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.7k stars 458 forks source link

Attempting to `.get_partial_message()` from a `PartialMessageable` results in an Exception #2543

Closed DefiDebauchery closed 1 week ago

DefiDebauchery commented 1 month ago

Summary

Exception thrown when trying to construct a PartialMessage from a PartialMessageable

Reproduction Steps

A help file for .partial-objects in the Pycord Discord states the following:

Partial Objects

These can be used to make API calls when you have channel id and/or message id, and you don't want to rely on the cache to have their objects.

Methods which can be used on them are

  • Partial Messageable (analogous to a Channel) - Docs
  • Partial Message (analogous to a Message) - Docs

    Example Usage:

    async def star_message(channel_id: int, message_id: int):
    # Get Partial Messageable object
    partial_channel = bot.get_partial_messageable(channel_id)
    
    # Get Partial Message
    partial_message = partial_channel.get_partial_message(message_id)
    
    # Add a reaction
    await partial_message.add_reaction(":star:")

The issue is that PartialMessage checks the incoming type, and PartialMessageable, as constructed and returned by .get_partial_messageable(), is not on that list.

Minimal Reproducible Code

async def star_message(channel_id: int, message_id: int):
    # Get Partial Messageable object
    partial_channel = bot.get_partial_messageable(channel_id)

    # Get Partial Message
    partial_message = partial_channel.get_partial_message(message_id)

    # Add a reaction
    await partial_message.add_reaction(":star:")

await star_message(881224361015672863, 1273298167768682611)

Expected Results

A PartialMessage object is provided for further interaction

Actual Results

An exception is thrown due to PartialMessageable not in the list of valid channel types for PartialMessage

Intents

any

System Information

Checklist

Additional Context

No response

NeloBlivion commented 1 month ago

This is intended to be changed, but you can circumvent this by setting type in get_partial_messageable