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

fix(commands): Fix handling of pulling context #335

Merged

Conversation

VelvetToroyashi
Copy link
Contributor

This PR fixes an issue wherein Remora would not correctly pull from the context when resolving partial messages. This poses an issue where the user cannot access member information via the API (e.g., an HTTP bot).

The issue in question is that when presented with an IPartialMessage parameter, the parser will always attempt to resolve the message via REST, which, under normal circumstances would be fine; this is generally desirable behavior for text commands, but is detrimental to slash commands, and especially context menus where this is enforced (e.g., you must have the message parameter.)

Regardless, there is a very simple fix, but before that I wanted to explain why this is an issue to being with.


The issue doesn't lie in the actual API logic, but the delegation to the "base" implementation of the class.

The reason this happens is because of type erasure; more specifically the object overloads on parsers, which are abstracted away by AbstractTypeParser<TParser>, which is how this bug arose to begin with. Remora doesn't invoke the generic method at runtime despite Remora.Commands checking for parser types by the service-locator pattern, and instead invokes the type-erased method, which could really do anything.

@Nihlus Nihlus merged commit 0a4c6e8 into Remora:main Apr 29, 2024
4 checks passed
VelvetToroyashi added a commit to VelvetToroyashi/Palladium that referenced this pull request May 9, 2024
This is a temporary parser type that'll be removed when Remora releases a new version which includes the following patch:  Remora/Remora.Discord#335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants