This would definitely be easier as a Flarum extension, as you could easily access app.current
to see whether you are in a discussion, and call app.composer.show(theCorrectComposer)
to open the composer accordingly.
This can technically be done from outside an extension too, but you need the full path to the classes from inside webpack.