Pycord-Development / pycord

Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
https://docs.pycord.dev
MIT License
2.69k stars 459 forks source link

Accessing Raw Interaction Data in `interaction_metadata` #2498

Closed DIPx69 closed 3 weeks ago

DIPx69 commented 3 weeks ago

Summary

In previous versions, raw interaction data could be accessed using message.interaction.data. However, since the 2.6 update, this method has changed

What is the feature request for?

The core library

The Problem

The issue is that since the 2.6 update, we can no longer access raw interaction data using message.interaction.data as we did previously

The Ideal Solution

  1. In interactions.py, within the InteractionMetadata class, add data to the __slots__.
  2. Set self.data = data within the class.

IMG_20240712_095811 IMG_20240712_095811

This modification allows you to access the raw interaction data as message.interaction.data, similar to the previous implementation before the 2.6 update

The Current Solution

No response

Additional Context

No response

Lulalaby commented 3 weeks ago

We can't add something, which does not exists anymore: image image

The difference between the old interaction info: image And the new interaction_metadata info: image is that:

I'm a bit confused tho why we would have had that before, since interaction infos on messages never had the real interaction saved, that'd have been a privacy concern to be honest (api side). I can imagine that we monkey-patched the last interaction data on it, but from discord side we never receive interaction.data on a message object.

Maybe I'm still too tired, but it seems like something we can't do?

@plun1331 / @NeloBlivion could you double check for me

NeloBlivion commented 3 weeks ago

I believe what they mean is that the old MessageInteraction class assigned self.data = data so you could access the raw data from Discord; the new InteractionMetadata class that replaced it does not do this (as an aside, I honestly think every Discord Model should assign the raw data as an attribute so that users can freely make use of it if necessary.)

Lulalaby commented 3 weeks ago

Ah fair, well we can leave that open then, but definitely low prio since it's nothing spec related

NeloBlivion commented 3 weeks ago

Indeed, pretty easy fix and you can still access the old message.interaction.data (or you should be able to? it's right above message.interaction_metadata)

plun1331 commented 3 weeks ago

Indeed, pretty easy fix and you can still access the old message.interaction.data (or you should be able to? it's right above message.interaction_metadata)

message.interaction is deprecated and could get removed, thus we would rather not rely on it

NeloBlivion commented 3 weeks ago

Ah of course, but in the short term they can still make use of it

DIPx69 commented 3 weeks ago

Ah of course, but in the short term they can still make use of it

I am using version 2.6 with the changes in the code, and my codebase is working fine. I hope these issue will be patched in the next update. Thanks for helping me

DIPx69 commented 3 weeks ago

Indeed, pretty easy fix and you can still access the old message.interaction.data (or you should be able to? it's right above message.interaction_metadata)

message.interaction is deprecated and could get removed, thus we would rather not rely on it

I can still use _interaction without any deprecated warnings

NeloBlivion commented 3 weeks ago

Don't think we included a warning in code because it'd trigger on every message without any user involvement, it's been marked as deprecated in the docs though (or maybe we could make it a property?)

DIPx69 commented 3 weeks ago

Don't think we included a warning in code because it'd trigger on every message without any user involvement, it's been marked as deprecated in the docs though (or maybe we could make it a property?)

As I know MessageInteraction class will be removed from the codebase in the next update.

Lulalaby commented 3 weeks ago

I am using version 2.6 with the changes in the code, and my codebase is working fine. I hope these issue will be patched in the next update. Thanks for helping me

It's not on our prio list so no promises.

What would be interesting is what property you want to get

Lulalaby commented 3 weeks ago

As I know MessageInteraction class will be removed from the codebase in the next update.

Most likely

DIPx69 commented 3 weeks ago

I am using version 2.6 with the changes in the code, and my codebase is working fine. I hope these issue will be patched in the next update. Thanks for helping me

It's not on our prio list so no promises.

What would be interesting is what property you want to get

name

Lulalaby commented 3 weeks ago

name

This is a property of a deprecated and soon to be removed field by discord. Try finding another solution, we won't support specifically that, as outlined in my first response here