-
Notifications
You must be signed in to change notification settings - Fork 116
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
Allow edited messages and interactions to be sent without removing existing embeds #301
Conversation
This is a breaking change because:
Target Additionally, the current behaviour is apparently more intuitive, and you still have access to the old embeds when handling a ReplyHandle, so its not like the current way is impossible to work with. Lines 107 to 111 in 5750259
The only thing with any mild annoyance is that there isn't a nice way to keep attachments without reuploading them like the serenity builders? |
Oop! My bad on the public field breaking change, did this very early in the morning. All good! The code you highlighted applies to replies, not interactions. Interactions force clear embeds every time, hence the referenced PR in Serenity core too, as this is incorrect on their side as well, which was my focus. However, by force-setting embeds every time, you actually explicitly remove all embeds, unless you supply the full embeds list again - and this is not supplied in the edit/reply builder. As for the embeds, feel free to correct me if I'm wrong as I'm just doing a code walk, not running tests against Poise itself (though I created the pair of PRs out of observed misbehavior, and tested against the API directly) - but from what I understand that's not how that code works, and the comment is outdated.
Now here's where things go wrong: When generating these, you then always explicitly set In the case of interactions, it gets worse - while the same behavior as above applies, serenity itself steps on your toes itself in the case of editing the followup interaction responses (though not the initial one). Even if you prevent this, serenity made the embeds field mandatory by mistake. The serenity-side PR mentioned in my initial comment fixes that, and a similar fix was merged previously for the Poise use this in your own pagination builtin, when pagination occurs on the initial message, if triggered by an interaction such as a slash command. You don't see any issues with yours because you rebuild the embed for every page, but in situations where this is not the case, this breaks. The test code used to perform this in verifying my claims in this comment, using xh (replace with curl or your favourite HTTP API testing software): send() {
xh $1 "https://discord.com/api/v10/$2" Authorization:'Bot <token>' User-Agent:'DiscordBot (<url>, 0.0.1)' ${@:3}
}
# Create the message, take note of the ID
send POST channels/<channelid>/messages content=hi embeds:='[{"title":"hi"}]'
# This will edit the message, but not remove embeds
send PATCH channels/<channelid>/messages/<msgid> content=hello
# This will remove the existing embed, and replace it with the one given here.
send PATCH channels/<channelid>/messages/<msgid> content=hello embeds:='[{"title":"hello"}]'
# This will remove all embeds, and is what Poise does by default
send PATCH channels/<channelid>/messages/<msgid> content=hello embeds:='[]' |
Am I missing anything here? You mention editing the response which |
When calling
|
Fixes serenity-rs#300 # Conflicts: # src/reply/builder.rs
Trying to get it properly on poise next. Will reopen once I get it sorted. |
Take this as a lesson to stop opening PRs from the main branch of your fork. |
I mean, that's the flow github offers up now. Used to not, used to autogenerate a branch called patch-1. I guess something changed. Either way, opened #302. |
Allows replies to be sent with embeds nulled out in the API, which prevents removing existing embeds under the context of editing an existing message response, both for interactions and standard messages.
This changes existing behavior - now, when not setting any embeds, existing embeds are kept. To clear them, you would call
reply.embeds(vec![])
Pairs with serenity-rs/serenity#2968 - this change can be made without it, but together they fix followup messages too. They can be merged separately, though the documentation on the
embed()
method is considered incorrect until this is merged on Serenity's side.Fixes #300