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

Add MessageReferenceKind enum #2996

Merged
merged 11 commits into from
Nov 11, 2024
Merged

Conversation

MarkusTheOrt
Copy link
Contributor

Fixes #2994

also adds additional From<> implementation for (MessageReferenceKind, ChannelId, MessageId)

@github-actions github-actions bot added the model Related to the `model` module. label Oct 18, 2024
@GnomedDev
Copy link
Member

I don't think we should continue adding Froms for this type as it will just get silly if there are more message reference types added. Can you remove the one you added in this PR and add #[deprecated] to the existing one?

@MarkusTheOrt
Copy link
Contributor Author

also right now the kind is an option, however the discord API docs say that this is a required field in the future. So maybe just make it a Non-Optional type now?

@GnomedDev
Copy link
Member

Sure, chuck a serde default on there as-well to make sure old MessageReferences without the field set still deserialize.

src/model/channel/message.rs Outdated Show resolved Hide resolved
@MarkusTheOrt
Copy link
Contributor Author

20241018_16h51m35s_grim
I can confirm its working

@MarkusTheOrt
Copy link
Contributor Author

MarkusTheOrt commented Oct 18, 2024

To use the forward message feature the bot needs to have at least the "Read Message History" permissions, (I don't know about reply but I believe that too), should I put a comment there to clarify things?

@MarkusTheOrt
Copy link
Contributor Author

so while this code is all fine, I think its better to go with a builder and use a CreateMessageReference struct instead of the MessageReference struct, that way one can set all the fields they want in the way it works with everything else.

@GnomedDev
Copy link
Member

We are moving away from documenting stuff like that as it may change in future. If it's documented on ddev docs, it wouldn't be the end of the world to duplicate here, but if not we shouldn't.

@github-actions github-actions bot added the builder Related to the `builder` module. label Oct 18, 2024
@MarkusTheOrt
Copy link
Contributor Author

this looks a lot more reasonable to me, let me know what you think

@@ -209,7 +210,7 @@ impl CreateMessage {
}

/// Set the reference message this message is a reply to.
pub fn reference_message(mut self, reference: impl Into<MessageReference>) -> Self {
pub fn reference_message(mut self, reference: impl Into<CreateMessageReference>) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change, and either requires targeting to the next branch or reverting. I would prefer reverting, as we should have support for new discord features on current.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I'll open a PR for next once this is done so we don't forget :-)

Copy link
Member

@jamesbt365 jamesbt365 Oct 18, 2024

Choose a reason for hiding this comment

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

Dont open multiple PRs, the 2 branches are rebased on each other to keep feature parity so whoever rebases it will remove it. Opening multiple PRs will just diverge the branches and make rebasing in the future a pain.

src/builder/create_message.rs Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this completely unused now? This shouldn't be added for current, you can make a separate PR after this is merged and next is rebased to add this builder and swap CreateMessage::reference_message to use this.

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 can remove this if you want, but I made an from impl to convert a CreateMessageReference into a MessageReference, so not 100% unused but I get your point.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, please remove it for now.

@GnomedDev GnomedDev merged commit 7bc55b8 into serenity-rs:current Nov 11, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builder Related to the `builder` module. model Related to the `model` module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update MessageReference Struct
3 participants