Repository navigation
fix: Plugin API: passing a MessageElement to Message:append_element - #7176
Merged
pajlada merged 3 commits intoAug 15, 2026
Merged
Conversation
Contributor
|
Thank you, good catch! Can you add a test in https://github.com/Chatterino/chatterino2/blob/bf87302eb4837397a498d7a669860e859949b588/tests/lua/message/clone.lua (or some other file)? You can add a new function to the |
Contributor
Author
|
@Nerixyz thanks for responding so quickly. I've added a test as a new |
pajlada
approved these changes
Aug 15, 2026
pajlada
enabled auto-merge (squash)
August 15, 2026 22:41
babicekmarek
pushed a commit
to babicekmarek/streamally-chatterino
that referenced
this pull request
Sep 14, 2026
…tterino#7176) When passing a `MessageElement` instead of an init table to `Message:append_element` in a lua plugin, it would error with "Invalid message type" suggesting that it calls `elementFromTable`, i.e. acts as if a `MessageElementInit` table was passed. ``` Reviewed-by: Nerixyz <nerixdev@outlook.de> Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When passing a
MessageElementinstead of an init table toMessage:append_elementin a lua plugin, it would error with "Invalid message type" suggesting that it callselementFromTable, i.e. acts as if aMessageElementInittable was passed.Reordering the sol::overload so that the
Message:append_element(MessageElement)one comes fixes this. I'm not 100% sure on this but it seems that the passed message element somehow matches as asol::tableunder the hood so the MessageElementInit overload matches before MessageElement gets checked. With the order from this pr both passing a MessageElement and a MessageElementInit works as should.Small example to test: